Places information about files into an array and then returns the number of files.
ADIR(ArrayName [, cFileSkeleton [, cAttribute [, nFlag]]])
Specifies the name of the array. If the array you include doesn't exist, Visual FoxPro automatically creates the array. If the array exists and isn't large enough to contain all the information, Visual FoxPro automatically increases the size of the array to accommodate the information. If the array is larger than necessary, Visual FoxPro truncates the array. If the array exists and ADIR(В ) returns 0 because no matching files are found, the array remains unchanged. If the array doesn't exist and ADIR(В ) returns 0, the array isn't created.
The following table describes the contents and data type of each column in the array:
The last array column contains the file attributes of the matching files. Each file attribute is expressed by a letter; a file can have more than one attribute. The following table indicates the file attribute represented by each letter:
Column Array contents Data type
Dates last modified
Times last modified
Archive вЂ“ Read/Write
- Specifies a file skeleton so you can store information about files with names or extensions that match a search criterion. For example, the criterion can be all tables, all text files, all files with names that have A as their first letter, and so on. Such general searches are done by including the wildcards * and ? in cFileSkeleton. A question mark represents a single character; an asterisk represents any number of characters. You can use any number of wildcards in any position within the file skeleton. You can specify a drive and/or directory to search for matching file names. If you don't specify a drive and a directory, Visual FoxPro places information about files in the current directory into the array.
- Specifies the inclusion of subdirectories and hidden or system files. cAttribute can contain any combination of D, H, and S. Including D returns subdirectory names of the current directory in addition to file names that match the file skeleton specified in cFileSkeleton. Including H returns information about hidden files that match the file skeleton specified in cFileSkeleton. Including S returns information about system files that match the file skeleton specified in cFileSkeleton. Include an empty string in cFileSkeleton to return just subdirectory names, hidden files or system files. You can include V in cAttribute to return the volume name of the current drive. Only the volume name is returned to the array if V is included with D, H, or S. The volume name is stored in the first array element and the remainder of the array is truncated.
Specifies whether the display provides DOS naming or actual case sensitivity.
(Default) Display represents the full file name in uppercase
Display represents original Case in names
Display follows DOS 8+3 naming convention
For each file, ADIR(В ) places into the array the file name, size, date last modified, time last modified, and attributes.
The following example uses ADIR(В ) to create an array containing database information. The names of the databases are then displayed.
CLOSE DATABASES SET DEFAULT TO (HOME(2) + 'Data') gnDbcnumber = ADIR(gaDatabase, '*.DBC') && Create array CLEAR FOR nCount = 1 TO gnDbcnumber && Loop for number of databases ? gaDatabase(nCount,1) && Display database names ENDFOR SET PATH TO HOME( ) && Set path to Visual FoxPro directory