Public Function upload tree (tree: Tree, item: object, startatparent: Boolean = false): void
{
// Get the tree's data Descriptor
VaR descriptor: itreedatadescriptor = tree. datadescriptor;
VaR cursor: iviewcursor;
VaR parentitem: object;
VaR childitem: object;
VaR childitems: object;
// If the item is null, stop
If (item = NULL)
Return;
// Do we back up one level to the item's parent
If (startatparent)
{
// Get the parent
Parentitem = tree. getparentitem (item );
// Is the parent real
If (parentitem)
{
Trace ("| -- parent node", parentitem [tree. labelfield]);
// If the parent is a branch
If (descriptor. isbranch (parentitem ))
{
// If the branch has children to run through
If (descriptor. haschildren (parentitem ))
{
// Get the children of the Branch
// This Part of the algorithm contains the item
// Passed
Childitems = descriptor. getchildren (parentitem );
}
}
// If the branch has valid child items
If (childitems)
{
// Create our back step cursor
Cursor = childitems. createcursor ();
// Loop through the items parent's children (item)
While (! Cursor. afterlast)
{
// Get the current Child item
Childitem = cursor. Current;
VaR label: String = childitem [tree. labelfield];
VaR branch: Boolean = descriptor. isbranch (childitem );
// Good place for a custom method ()
Trace ("sibling nodes:", label, "Is Branch:", Branch );
// If the child item is a branch
If (descriptor. isbranch (childitem ))
// Traverse the childs branch all the way down
// Before returning
Tree (tree, childitem );
// Do it again!
Cursor. movenext ();
}
}
}
}
Else // we don't want the parent or this is the second iteration
{
// If we are a branch
If (descriptor. isbranch (item ))
{
// If the branch has children to run through
If (descriptor. haschildren (item ))
{
// Get the children of the Branch
Childitems = descriptor. getchildren (item );
}
// If the child items exist
If (childitems)
{
// Create our cursor pointer
Cursor = childitems. createcursor ();
// Loop through all of the children
// If one of these children are a branch we will recurse
While (! Cursor. afterlast)
{
// Get the current Child item
Childitem = cursor. Current;
VaR label: String = childitem [tree. labelfield];
VaR branch: Boolean = descriptor. isbranch (childitem );
// Good place for a custom method ()
Trace ("-- sub node:", label, "Is Branch:", Branch );
// If the child item is a branch
If (descriptor. isbranch (childitem ))
// Traverse the childs branch all the way down
// Before returning
Tree (tree, childitem );
// Check the next child
Cursor. movenext ();
}
}
}
}
}
////////////////
DFS. You can use it.