File_ListDir()

Parent Previous Next

File_ListDir(), String * 8


Result String  = name of directory

0 = end of list

String * 8 = directory name


Get Currently Listed Directory Name


File_ListDir() is a command used to retrieve the name of the directory currently being processed in a sequential list of directories. It works in conjunction with File_ListReset() and other file listing commands to allow you to loop through directories on an SD card or other storage media.


Example:

File_ListDir()


How It Works:

File_ListDir() is used to get the name of the directory at the current position in the list. After calling this command, the internal counter is automatically incremented, moving to the next directory in the list.

• It returns a string with the directory name. If there are no more directories, it returns 0 to indicate the end of the list.


Important Notes:

• End of List: When there are no more directories to list, File_ListDir() returns 0, signaling the end of the list.

• Directory Names: The directory names are retrieved in the order they are found in the FAT table.

• File List Reset: Always reset the list with File_ListReset() before using File_ListDir() to ensure you start from the beginning of the directory list.


TftSetUp(0)                                                                                 'Set screen

TftResetScreen(BLACK)                                                                       'Reset screen

TftSetSndFont(0,0)                                                                          'Set Font0

While File_Init() <> cErrOK : Wend                                                          'Initialize SD Card

TftPrintSndString("Sd Initialization OK",1,0,0,1,GREEN,BLACK,0)                             'Confirm Initialize SD Card

bCounter = 27                                                                               'Vertical print counter

File_ListReset()                                                                            'Reset file/folder counter

Do       

    Clear sString                                                                                   

    sString = File_ListDir()                                                                'Loop through folder names

    If sString = 0 Then Break                                                               'Break if end of list

    TftPrintSndString(sString,1,0,bCounter,1,GREEN,BLACK,0)                                 'Print folder name

    Dec bCounter                                                                            'Move to next print line

Loop

bCounter = 27                                                                               'Vertical print counter

File_ListReset()                                                                            'Reset file/folder counter

Do                                                                                          'Loop through file names

    Clear sString

    sString = File_ListFile()

    If sString = 0 Then Break                                                               'Break if end of list

    TftPrintSndString(sString,1,20,bCounter,1,WHITE,BLACK,0)                                'Print folder name

    Dec bCounter                                                                            'Move to next print line

Loop






Created with the Personal Edition of HelpNDoc: Elevate Your Documentation Process with HelpNDoc's Advanced Features