Hello World!
I am trying to understand recursion.
Can anyone please show me how to make this test case work?
I am trying to understand recursion.
Can anyone please show me how to make this test case work?
Global csd ; currently selected directory Global dir$, root$="C:\Program Files" ; lets try it on this Global fileout=WriteFile("C:\log.txt") ; write a log here ListDir( root$ ) ; call the recursive function CloseFile fileout ; close the log End Function ListDir( dir$ ) WriteLine( fileout, dir$) csd=ReadDir(dir$) Repeat file$=NextFile(csd) If 2=FileType(file$) And file$>".." ; a candidate? dir$=dir$+""+file$ ; add to the filepath WriteLine( fileout, dir$) ; and record it csd=ReadDir(dir$) ; select the new path ListDir(dir$) ; and read the contents EndIf file$=NextFile(csd) If 1=FileType(file$) Then WriteLine(fileout, file$) ; log any filenames EndIf Until file$="" End Function