DIR()

Top  Previous  Next

 

The DIR() function returns the contents of an operating system directory.

 

 

Format

 

DIR(pathname)

 

where

 

pathnameidentifies the operating system directory to be processed.

 

 

The DIR() function returns a dynamic array with one field per entry in the specified directory. Each field contains two items separated by value marks:

Value 1The item name. On platforms with case insensitive file names, the text returned preserves the casing used by the underlying operating system.
Value 2The item type. This is F for a file or D for a directory.
Value 3File modes. On Windows and PDA systems, this is a collection of letters representing the file attributes:

A = archive

C = compressed

H = hidden

R = read only

S = system

T = temporary

On other platforms, this value contains the file permissions as a decimal value.

 

 

The standard . and .. directory entries are not returned.

 

Applications should not assume that this structure will remain unchanged. Additional values may appear in future releases.

 

 

Example

 

FILES = DIR('C:\MYDIR')

NUM.FILES = DCOUNT(FILES, @FM)

FOR I = 1 TO NUM.FILES

  IF FILES<I,2> = 'F' THEN DISPLAY FILES<I,1>

NEXT I

 

The above example lists all the files in C:\MYDIR, omitting subdirectories.