FINDNEXT

Top  Previous  Next

Syntax

STRING = FINDNEXT(handle as UINT, OPT attrib as POINTER)

Description

After a directory is successfully opened with the FINDOPEN function use FINDNEXT to retrieve the filenames in a loop.

Parameters

handle - [in] Value returned by the FINDOPEN function.

attrib - [out] Optional. The files attributes stored as an integer value.

Return value

A string containing the filename, or and empty string "" when all files have been read.

Remarks

Returned filename does not include the path. The optional attrib parameter must be defined as an integer type and will receive the returned files attributes. The attributes are a bit mask that can contain one or more of the following:

@FILE_ARCHIVE

@FILE_COMPRESSED

@FILE_DEVICE

@FILE_DIRECTORY

@FILE_ENCRYPTED

@FILE_HIDDEN

@FILE_NORMAL

@FILE_READONLY

@FILE_SYSTEM

See Also: FINDOPEN, FINDCLOSE

Example usage

OPENCONSOLE
DEF dir:UINT
DEF filename:STRING
 
dir = FINDOPEN("c:\\*.*")
IF(dir)
    DO
        filename = FINDNEXT(dir)
        PRINT filename
    UNTIL filename = ""
    FINDCLOSE dir
ENDIF
 
PRINT "Press Any Key"
DO:UNTIL INKEY$ <> ""
 
CLOSECONSOLE
END

Example returning only directories:

OPENCONSOLE
DEF dir,attrib:UINT
DEF filename:STRING
 
dir = FINDOPEN("c:\\*.*")
IF(dir)
    DO
        filename = FINDNEXT(dir,attrib)
        IF attrib & @FILE_DIRECTORY THEN PRINT filename
    UNTIL filename = ""
    FINDCLOSE dir
ENDIF
 
PRINT "Press Any Key"
DO:UNTIL INKEY$ <> ""
 
CLOSECONSOLE
END