Dir
(Engine-Level Function)
Description: | Performs a search in the given directory and returns an array of matching file names. |
Returns: | Array |
Usage: | Script only. |
Function Groups: | File I/O |
Related to: | DriveInfo | FileFind | FileDialogBox | GetFileAttribs |
Format: | Dir(Path, Attributes, Option) |
Parameters: |
Path | |||||||||||||||||||||||||||
Required. Any text expression that indicates the full path name for the directory to list. The search is non-recursive (i.e. it considers only the specified directory, not any of its sub-directories). Path may include a wildcard, such as "*.DAT". A known path alias for File-Related Functions may be provided in the form, :{KnownPathAlias}. | |||||||||||||||||||||||||||
Attributes | |||||||||||||||||||||||||||
Required. Any numeric expression that gives the attributes to match on each file listed. Files that don't match these attributes won't be listed. The Attribute parameter may be set as one of the following:
|
Option | |||||||||||||||||||||||||||||||||
Required. Any numeric expression giving the type of text information to generate. All information is placed in a single text string (which will be stored in an element of the array that is created). The information is written from left to right, with lowest option numbers first.
|
Comments: |
This function returns an array of text values, where each element contains the information specified by Option for each file that matches both Path and Attributes. If no files are found, the return value will be set to invalid. Notice that the only difference between this function and the FileFind function is that FileFind searches down through the whole directory tree, while this function looks in the immediate directory only. If you are looking for a "browse for folder" dialog box, please refer to the FileDialogBox function. |
Example:
If ! ValidValid(datFiles); [ DatFiles = Dir("G:\Research\*.DAT" { Path }, 0 { All normal files }, 1 { Retrieve file name }); ]
To display the first entry, try:
ZText(10, 10, DatFiles[0], 15, 0);
The result might be something like:
"TEST.DAT"