Description: This function performs a search in the given directory and returns an array of matching file names.
Returns: Array
Usage: Script
Format: Dir(Path, Attributes, Option)
Parameters:
Path {
numeric } { required } { no default
}
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".
Attributes { numeric } { required } {
no default }
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:
|
Attribute |
Bit No. |
Meaning |
|
0 |
- |
Files without attributes |
|
8 |
3 |
All files (regardless of attributes) |
or, it may be constructed by adding together the numbers from the table below:
|
Attribute |
Bit No. |
Meaning |
|
1 |
0 |
Read only |
|
2 |
1 |
Hidden |
|
4 |
2 |
System |
|
16 |
4 |
Sub-directory |
|
32 |
5 |
Archive |
Option { numeric } { required } { no
default }
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.
|
Option |
Bit No. |
Description |
|
1 |
0 |
Short file name |
|
2 |
1 |
Full path and file name |
|
4 |
2 |
File size |
|
8 |
3 |
File last modified date (in text) |
|
16 |
4 |
File last modified time (in text) |
|
32 |
5 |
File attributes (ADHRS) |
|
64 |
6 |
File last modified date/time combination (in seconds since January 1, 1970) |
|
128 |
7 |
File creation date (in text) |
|
256 |
8 |
File creation time (in text) |
|
512 |
9 |
File creation date/time combination (in seconds since January 1, 1970) |
The attributes returned as a result of bit 5 being set are printed as the capital letters A (archive) D (subdirectory), H (hidden), R (read-only), and S (system).
Comments: This function returns a pointer to an array of text values listed in reverse alphabetical order. Each text value 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"
See Also: