# findfirst

Searches for the first file matching a string.

    findfirst <dir handle> <file name> <strvar>

## Remarks

The findfirst command searches for the first file matching the specified file name <file name>.
If the file is found, this command returns the directory handle in <dir handle>, returns the first file name in <strvar> and sets the system variable "result" to 1.
Otherwise, <dir handle>, <strvar> and "result" are set to -1, "" and 0, respectively.
If the findfirst command find the first file successfully, the directory handle can be used for the findnext command to search for the next file matching the specified <file name>.
The directory handle should be released by the findclose command.

# findnext

Searches for the next file matching a string.

    findnext <dir handle> <strvar>

## Remarks

The findnext command searches for the next file matching the file name specified in the findfirst command.
The integer value <dir handle> should be the directory handle returned by the findfirst command.
If the next file is found, the file name is returned in <strvar> and "result" is set to 1.
Otherwise, <strvar> and "result" are set to "" and 0, respectively.

# findclose

Releases a directory handle.

    findclose <dir handle>

## Remarks

The findclose command releases the directory handle <dir handle> returned by the findfirst command.
As soon as the file operation ends, this command should be executed.

## Example

    extpat='*.txt'
    findfirst dh extpat filename

    while result
    	messagebox filename extpat
    	findnext dh filename
    endwhile

    findclose dh