FindNext


Function FindNext()


Returns a string which is the name of the next file that matches a filespec set in a previous call to FindFirst .


Syntax a = FindNext()


Remarks

FindNext is made after a preceding call to FindFirst. FindNext will return a string that represents the next file that matches the parameters given in the call to FindFirst. If the list of matching files is exhausted, FindNext returns the empty string "".


Notes: Just because a filename appears in a FindFirst / FindNext call, does not imply that it is available to be read or written. Files that are open by other processes, are read-only, etc. May be listed, but for other reasons cannot be opened.


See Also:

FindFirst File and Directory functions


Example Script 1


NUMBER x

STRING a,b = "C:\*.*"


a = FINDFIRST(b,1 + 2 + 4) ' retrieve read-only, hidden, system files

WHILE LEN(a)

PRINT a

x ++

a = FINDNEXT()

WEND


PRINT "There are "; x; " read-only, hidden, system files in c:\"


Script Output

(your results may be different)


BOOTLOG.TXT

COMMAND.COM

SUHDLOG.DAT

FRUNLOG.TXT

MSDOS.---

SETUPLOG.TXT

NETLOG.TXT

CVT.LOG

DETLOG.TXT

CONFIG.SYS

BOOTLOG.PRV

SYSTEM.1ST

IO.SYS

autoexec.bat

ffastun0.ffx

SCANDISK.LOG

MSDOS.SYS

AUTOEXEC.PCC

ffastun.ffo

ffastun.ffl

ffastun.ffa

AUTOEXEC.001

stub.log

AUTOEXEC.B~2

AILog.txt

CONFIG.WIN

SETUPLOG.OLD

There are 27 read-only, hidden, system files in c:\


- - - -

Example Script 2

NUMBER x

STRING a,b


a = CWD()

IF MID(a,LEN(a),1) <> "\" THEN

a = a + "\"

ENDIF


b = a + "*.txt"


a = FINDFIRST(b) ' retrieve matching files in the current working directory.

WHILE LEN(a)

IF FOPEN(1,a) THEN

x ++

PRINT "The first line from "; a; " is: ";

PRINT FGETS(1)

FCLOSE(1)

ENDIF

a = FINDNEXT()

WEND


Script Output

(your results may be different)


The first line from CHDIR.txt is: IF CHDIR("C:\Temp") THEN

The first line from CHR.txt is: NUMBER i,j

The first line from COS.txt is: NUMBER i = 0

The first line from CWD.txt is: STRING a

The first line from EXP.txt is: NUMBER e

The first line from EXP10.txt is: ' Let's check the first 5 powers of 10

The first line from EXP2.txt is: ' Let's enumerate the powers of 2 from 0 to 7

The first line from ABS.txt is: NUMBER i

The first line from ACOS.txt is: NUMBER pi = 3.141592654

The first line from ASC.txt is: STRING a = "Hello"

The first line from ASIN.txt is: NUMBER pi = 3.141592654

The first line from ATN.txt is: NUMBER i = 45

The first line from FCLOSE.txt is: NUMBER x = 1,i

The first line from FCLOSEALL.txt is: NUMBER x = 1,i

The first line from FEOF.txt is: NUMBER x = 1

The first line from FGETC.txt is: NUMBER x = 1

The first line from FGETS.txt is: NUMBER x = 1

The first line from FILEEXISTS.txt is: STRING a = "*.txt"

The first line from FILELEN.txt is: STRING a

The first line from FINDFIRST Example 1.txt is: NUMBER x

The first line from FINDFIRST Example 2.txt is: NUMBER x

The first line from FINDNEXT Example 1.txt is: NUMBER x

The first line from FINDNEXT Example 2.txt is: NUMBER x