Click or drag to resize

ADir Function

X#
Fill a series of arrays with directory information. Note:
ADir() is a compatibility function and therefore not recommended.
It is superseded by the Directory() function, which returns all file information in a multidimensional array.

Namespace:  XSharp.RT
Assembly:  XSharp.RT (in XSharp.RT.dll) Version: 2.21
Syntax
 FUNCTION ADir(
	cFileSpec,
	acFileNames,
	anSizes,
	adDates,
	acTimes,
	acAttributes
) AS DWORD CLIPPER
Request Example View Source

Parameters

cFileSpec (Optional)
Type: Usual
The file specification for the directory search.
Besides a file name, this specification may include an optional drive, directory, and extension.
The file name and extension may include the standard wildcard characters (* and ?).
If you do not specify a drive and directory, this function uses the SetDefault() setting.
acFileNames (Optional)
Type: Usual
The array to fill with the file names matching cFileSpec.
Each element will contain the file name and extension as a string, in all uppercase letters.
anSizes (Optional)
Type: Usual
The array to fill with the sizes of the corresponding files in acFileNames.
adDates (Optional)
Type: Usual
The array to fill with the dates of the corresponding files in acFileNames.
acTimes (Optional)
Type: Usual
The array to fill with the times of the corresponding files in acFileNames, in the form hh:mO:ss.
acAttributes (Optional)
Type: Usual
The array to fill with attributes of the corresponding files in acFileNames.
If acAttributes is specified, hidden, system, and directory files are included as well as normal files.
If acAttributes is not specified, only normal files are included.

Return Value

Type: DWord
The number of files matching the directory skeleton described in cFileSpec.
Remarks
ADir() performs two basic operations.
First, it returns the number of files matching the file specification.
Second, it fills a series of arrays with file names, sizes, dates, times, and attributes.
Note that all of the array arguments must exist prior to calling this function and must be of a large enough size to hold the function results.
Tip Tip
If you specify acAttributes, and cFileSpec contains a pattern, such as "*.*" or "*.", that matches directory names, directories are included in acFileNames.
They are indicated with an attribute value of "D."
If ADir() is executed within a subdirectory, the first two entries of acFileNames are "." and "..", the parent and current directory aliases.
The date and time of last update are reported for directories, but the size of a directory is always 0.
Examples
This example creates an array to hold the names of all .TXT files in the current default directory, then uses AEval() to list them to the console:
X#
1LOCAL aFiles AS ARRAY
2aFiles := ArrayCreate(ADir("*.txt"))
3ADir("*.txt", aFiles)
4AEval(aFiles, {|element| QOut(element)})
See Also