Up to know we have discussed instructions and operations that were dealing with files. To access a file you needed to know the name of the file. Many times the program does not know the file and needs to get the list of all files in a certain directory. To do this you can use the commands OPEN DIRECTORY, CLOSE DIRECTORY and the function NextFile.
The command OPEN DIRECTORY opens a directory for getting the list of the file. The command reads the list of the files and creates an internal list of the files.
The function NextFile can be used to retrieve the files of the directory opened one by one. When the last file name has been retrieved or when there is no need to retrieve the remaining file names the command CLOSE DIRECTORY should be used to close the listing.