FINDFIRST$ function

Purpose:

FINDFIRST$ returns the first file in the current directory matching the file specification.

Syntax:

RetStr = FINDFIRST$(FileSpec AS STRING)

Return Value:

  • Data type: STRING
    RetStr The name of first file in the current directory matching FileSpec.

Parameters:

  • Data type: STRING
    FileSpec A string literal or variable containing file specification.

Example:

The following example will copy all the files from C:\Temp to C:\Temp\Junk.

DIM F$
F$ = FINDFIRST$("*.*")
WHILE F$ > ""
  COPYFILE "C:\Temp\" + F$, "C:\Temp\Junk\" + F$
  F$ = FINDNEXT$
WEND

Remarks:

The F$ = FINDFIRST$("*.*") will return the first file in the current directory, that is, the directory from which the application is being run. To enumerate the files in some other directory, either add a

CHDIR "C:\SomeOtherdirectory"

or else use

F$ = FINDFIRST$("C:\Anotherdirectory\*.*").

FINDNEXT$ function

Purpose:

Returns the next file in the current directory matching the FINDFIRST$ FileSpec file specification argument.

Syntax:

RetStr = FINDNEXT$

Return Value:

  • Data type: STRING
    RetStr The name of next file in the current directory matching FileSpec.

Parameters:

  • None.

BCX Console Sample Programs using the FINDFIRST$ and FINDNEXT$ functions.