ListFiles
ListFiles (FB)
ListFiles (FB)FUNCTION_BLOCK ListFiles EXTENDS CBML.ETrig
ListFiles
The ListFiles The function block enables listing files in a directory. This function block offers configuration options for the directory, sorting criteria and a filter for file names.
Representation

Usage
The block is used to read files in a specified directory, filter them and return information about the found files and directories.
Inputs
sDirectoryName: STRING(254) The path of the directory to be searched. By default this is './'.
eSortBy: SORT_BY The criterion by which the files should be sorted. By default this is by last modification date.
sContains: STRING A filter that specifies which substring the file names must contain. By default this is '.csv'.
itfFileList: COL.ISortedList2 An interface to a sorted list into which the filtered file entries are inserted.
Outputs
udiFilesInDirectory: UDINT The total number of files in the directory.
udiDirectoriesInDirectory: UDINT The number of directories in the directory.
udiFilteredFilesInDirectory: UDINT The number of files that match the filter criteria.
Processing logic
The FB opens the directory asynchronously and reads the file information.
For each file in the directory it checks whether it meets the filter criteria.
Filtered files are inserted into the provided sorted list.
The FB returns the number of files, directories and filtered files.
InOut:
Input
xExecute
BOOL
ETrig
Output
xDone
BOOL
ETrig
Output
xBusy
BOOL
ETrig
Output
xError
BOOL
ETrig
Input
sDirectoryName
STRING(254)
'./'
Input
eSortBy
SORT_BY
SORT_BY.LAST_MODIFICATION
Input
sContains
STRING
'.csv'
Input
itfFileList
COL.ISortedList2
Output
udiFilesInDirectory
UDINT
Output
udiDirectoriesInDirectory
UDINT
Output
udiFilteredFilesInDirectory
UDINT
Last updated

