f = DirectoryItems(d$)
See Generic For statement for details.
The table that is returned by DirectoryItems() as the second return value when
used in a generic For loop will have the following fields initialized:
Type:#DOSTYPE_FILE if the entry is a file or #DOSTYPE_DIRECTORY if
the entry is a directory.
Size:
Flags:
Time:
LastAccessTime:
CreationTime:
Comment:
Note that you can also manually traverse all files and sub-directories inside
a directory by using the OpenDirectory(), NextDirectoryEntry()
and CloseDirectory() functions. Using DirectoryItems(),
however, is often more convenient.
Function p_TraverseDir(d$, indent)
For s$,t In DirectoryItems(d$)
DebugPrint(RepeatStr(" ", indent) .. s$, t.time)
If t.type = #DOSTYPE_DIRECTORY
p_TraverseDir(FullPath(d$, s$), indent + 8)
EndIf
Next
EndFunction
p_TraverseDir("images", 0)
The function p_TraverseDir() can be used recursively print all files and sub-directories
in the given directory. The example call prints the contents of a directory named "images"
that must be stored relative to the script's path.