DIR

Action

Returns the filename that matches the specified filemask.

 

Syntax

sFile = Dir(mask)

sFile = Dir()

 

Remarks

SFile

A string variable that is assigned with the filename.

Mask

A file mask with a valid DOS filemask like *.TXT
Use *.* to select all files.

 

The first function call needs a file mask. All other calls do not need the filemask. In fact when you want to get the next filename from the directory, you must not provide a mask after the first call.

Dir() returns an empty string when there are no more file or when no file name is found that matches the mask.

 

 

ASM

Calls

_Dir ; with filemask

_Dir0 ; without filemask

Input

X : points to the string with the mask

Z : points to the target variable

Output

 

 

 

 

 Example

 

'Lets have a look at the file we created
Print "Dir function demo"
S = Dir( "*.*")
'The first call to the DIR() function must contain a file mask
' The * means everything.
'
While Len(s) > 0 ' if there was a file found
Print S ; " " ; Filedate() ; " " ; Filetime() ; " " ; Filelen()
' print file , the date the fime was created/changed , the time and the size of the file
S = Dir() ' get next
Wend