Jump to content

Looping through children in a tree


Recommended Posts

What's a clean way to loop through all of the children in a tree and print the structure out, using maybe spaces or hyphens to show the depth?

I'm thinking recursion..but is there a way to do it with just loops?

Edited by Tsukihime
Link to comment
Share on other sites

Hi.

What kind of tree are you talking about? File System - files - folders?

Regards, Rudi.

Why does it matter?

Tsukihime,

Check out the _GUICtrlTreeView_Level() and _GUICtrlTreeView_GetNext() functions from the help file. They should be enough to get you started.

Link to comment
Share on other sites

Why does it matter?

Because I imagined, he want's to process a filesystem structure tree.

You imagine, he's asking about...

_GUICtrlTreeView_Level()

_GUICtrlTreeView_GetNext()

But as he didn't answer neither your nor my question, it really doesn't matter :unsure:

Regards, Rudi.

Edited by rudi

Earth is flat, pigs can fly, and Nuclear Power is SAFE!

Link to comment
Share on other sites

I was just going off of the OP, and it simply asked how to iterate through a treeview control. To me that doesn't denote specific usage to be tailored too. I prefer to the modular approach; If you start broad enough you could "write" something that could work for many "treeview" control scenarios.

edit:

I didn't ask a question either. Just gave my response.

Edited by spudw2k
Link to comment
Share on other sites

I ended up just using a recursive function cause using a loop was too complicated to get it to do what I wanted =/

Func getChildren($root, $depth)
    If _GUICtrlTreeView_GetChildren($hObjTree, $root) Then
        $child = _GUICtrlTreeView_GetFirstChild($hObjTree, $root)
        while $child
            getChildren($child, $depth + 1)
            $child = _GUICtrlTreeView_GetNextChild($hObjTree, $child)
        WEnd        
    EndIf
    return 
EndFunc

Hi.

What kind of tree are you talking about? File System - files - folders?

Regards, Rudi.

Nothing specific.

It is just a function that will loop through any arbitrary TreeView object.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...