Server-Side JavaScript Example 5
Recursive List Enumeration
function displayList( listName )
{
// as we encounter a sublist while enumerating the properties we'll store
// it in this array rather then displaying it immediately so that we can
// group properties and sublists separately in the output
var subLists = new Array();
// display the name of the list and open an unordered list tag
RMAOutput( "" + listName + "\n" );
RMAOutput( "\n" );
var listIndex = 0 ;
var propName = RMAGetNthProperty( listName, listIndex );
while ( propName )
{
// test whether "propName" is a sublist
if ( RMAGetNthProperty( propName, 0 ) )
{
// store it in our array of sublists
subLists[ subLists.length ] = propName ;
}
else // display the property name/value
{
RMAOutput(
"- " + propName +
" = " +
RMAGetPropertyValue( propName ) +
"\n" );
}
propName = RMAGetNthProperty( listName, ++listIndex );
}
// now display each sublist via recursion
for ( var i = 0; i < subLists.length; i++ )
{
displayList( subLists[ i ] );
}
// close the list tag
RMAOutput( "
\n" );
}
displayList( "license.License0" );