DIR_LIST ​
DIR_LIST returns a list of files and dirs in a directory.
Syntax ​
leo-grammar
CC "AdoScript" DIR_LIST path:strValue [ filemask:strValue ] .
#--> RESULT ecode:intValue files:strValue dirs:strValue
Parameters ​
path
(strValue) - the directory to be listedfilemask
(strValue, optional) - specifies a format like ".htm". If no filemask is specified '' would be taken.
Returns ​
ecode
(intValue) - Contains the error code or 0 in case of success.files
(strValue) - Contains all the file names in the given directory, separated with '*'dirs
(strValue) - Contains all the directory names in the given directory, separated with '*'
Details ​
Relative paths relate to the current working directory (CWD).
All files and dirs are separated with a '**' because files may contain spaces.
The return variable ecode has the value 0 if no errors occurred, a value different than 0 if an error occurred.
See Also ​
Examples ​
Example 1 ​
asc
CC "AdoScript" DIR_LIST path:("c:\\")
IF (ecode != 0)
{
CC "AdoScript" INFOBOX ("Directory doesnt exist or an error occured.")
EXIT
}
SET myFiles:(replall(files,"**","\n"))
SET myDirs:(replall(dirs,"**","\n"))
CC "AdoScript" INFOBOX ("All files:\n\n" + myFiles + "\n\nAll dirs:\n\n" + myDirs)
Displays all files and subdirs of a directory in a infobox. Each file and dir in a line.
Example 2 ​
asc
CC "AdoScript" DIR_LIST path:("C:\\WINNT\\Help") filemask:("**.htm")
IF (ecode != 0)
{
CC "AdoScript" INFOBOX ("Directory doesn't exist or an error occurred.")
EXIT
}
SET myFiles:(replall(files,"**","\n"))
CC "AdoScript" INFOBOX ("All html-files:\n" + myFiles)
Displays all html-files of a directory in a infobox. Each file in a line.
Versions and Changes ​
Available since ADOxx 1.3