Hi :)
I'm trying to do an explorer like treeview but i get
problem with recursivity :( Anybody can help me ?
I'm trying to do an explorer like treeview but i get
problem with recursivity :( Anybody can help me ?
' createtreeview.bmx Strict Global window:TGadget=CreateWindow("My Window",50,50,240,240) Global treeview:TGadget=CreateTreeView(0,0,200,200,window) SetGadgetLayout treeview,2,2,2,2 Global root:TGadget=TreeViewRoot(treeview) Global Drive:String="C:" Global Direc:String="Program Files\2nd Speech Center" Global directory:TGadget directory=AddTreeViewNode(Drive,root) directory=AddTreeViewNode(Direc,directory) Global Previous:TGadget ListFiles(Drive+Direc) While WaitEvent() Print CurrentEvent.ToString() Select EventID() Case EVENT_WINDOWCLOSE End End Select Wend Function ListFiles( rootdir:String) Local dir:Int = ReadDir( rootdir) If Not dir Then Return 'If Not rootdir.EndsWith("/") Then rootdir:+ "/" Repeat Local fn:String = NextFile(dir) If Not fn Then Exit ' <-- this is important, we dont want an endless loop If fn = ".." Then Continue If FileType( rootdir+"/"+fn) = 2 And fn<>"." And fn<>".." Then If Previous<>Null directory=Previous Else Previous=AddTreeViewNode(fn,directory) EndIf ListFiles( rootdir+"/"+fn) ' <-- recurse over this folder Print "--------------------------------" 'Print "1) "+rootdir+"/"+fn 'Print "2) "+rootdir Print "3) "+fn Print "--------------------------------" Else 'Print rootdir+"/"+fn EndIf Forever CloseDir dir EndFunction