dir( ) example
The following example uses dir( ) to store the file information for all the files in the root directory of the current drive to the array aFiles. The file name and attributes string is displayed for all the files in the results pane of the Command window. Manifest constants to represent the columns are created with the #define preprocessor directive to make the code more readable.
#define ARRAY_DIR_NAME 1 // Manifest constants for columns returned by dir( )
#define ARRAY_DIR_SIZE 2
#define ARRAY_DIR_DATE 3
#define ARRAY_DIR_TIME 4
#define ARRAY_DIR_ATTR 5
aFiles = new Array() // Array will be resized as needed
nFiles = aFiles.dir("\*.*", "HS") // Include Hidden and System files
for nFile = 1 to nFiles
? aFiles[ nFile, ARRAY_DIR_NAME ]
?? aFiles[ nFile, ARRAY_DIR_ATTR ] at 25
endfor