Table of Contents

DirList function

Description

Returns a list of filenames from a directory and mask specified in a previous InitDir statement. The mask is used to create a selection of file names, using the standard DOS wildcards "*" and "?".

Syntax

filenames = DirList()

Parameters

The DirList function returns a dynamic array of the operating system filenames found in the directory masked by the InitDir statement.

With each use of DirList(), a list of filenames will be returned from the specified directory. DirList() may be placed in a loop to obtain all the filenames in a large directory. The loop would continue until the list is empty. Filenames are separated by field marks (ASCII character 254).

See Also

Drive(), SetInitDirOptions, InitDir

Example

/* Looks at each file in the C:\WINDOWS directory. Variable AB_COUNT keeps a count of the number of files with names starting with "A" or "B". */

InitDir "C:\WINDOWS\*.*"

AB_COUNT = 0

 

files = DirList()

 

position = 1

flag  = ""

Loop

   Remove this_file From files At position Setting flag

   first_letter = this_file[1,1]

   if first_letter _eqc "a" or first_letter _eqc "b" then

      AB_COUNT += 1

   end

While flag

Repeat

 

call msg(@window,"There are " : AB_COUNT : " files in the directory starting with an A or B.")

 
 
**
**