FB_EnumFindFileList

FB_EnumFindFileList 1:

This function block searches a directory for a file or a subdirectory whose name is similar to the specified name. Any entries found can be read individually. See also description of the FB_EnumFindFileEntry function block. The input parameter eCmd is used for navigating through the list of entries. The eCmd input determines whether the first or the next input is read, for example.

Background information

A new search may be started only if the previous search has been fully completed. The function block may need to be activated several times (by a rising edge at the bExecute input) for a complete search. The search is only fully complete if bEOE =TRUE was reached or if the search was terminated prematurely with ECMD = eEnumCmd_Abort.

For the TwinCAT system, the search may not yet be completed if the PLC application has already found the file or directory that was sought.

If not all entries are to be read (i.e. bEOE=TRUE is not reached), the function block subsequently has to be called with the input parameter eCmd = eEnumCmd_Abort. This is necessary in order to complete the search and release all internal resources (file handles). If bEOE=TRUE was reached or if an error occurs, eEnumCmd_Abort is automatically executed internally.

VAR_INPUT

VAR_INPUT
    sNetID      : T_AmsNetID;
    sPathName   : T_MaxString;
    eCmd        : E_EnumCmdType := eEnumCmd_First;
    pFindList   : DWORD;
    cbFindList  : UDINT;
    bExecute    : BOOL;
    tTimeout    : TIME := DEFAULT_ADS_TIMEOUT;
END_VAR

sNetId: Here a string containing the network address of the TwinCAT Computer can be given, whose system registration should be read. The string can also be empty for the local computer. 

sPathName: Valid directory name or directory with file name as string. The string can contain ( * and ?) as wildcards. If the path ends with a wildcard, dot or the directory name, the user must have access rights to this path and its subdirectories.

eCmd: Command parameter for the enumeration block.

pFindList: Array variable address (pointer variable) of type: ST_FindFileEntry.

cbFindList: Array variable byte size of type: ST_FindFileEntry.

bExecute: The command is executed with a positive edge at the input

tTimeOut: Maximum time allowed for the execution of the ADS command.

VAR_OUTPUT

VAR_OUTPUT
    bBusy       : BOOL;
    bError      : BOOL;
    nErrId      : UDINT;
    bEOE        : BOOL;
    nFindFiles  : UDINT;
END_VAR

bBusy: When the function block is activated this output is set. It remains set until and acknowledgement is received.

bError:  If an ADS error should occur during the execution of the command, then this output is set, after the bBusy output has been reset. 

nErrId: When the bError output is set, this variable supplies the ADS error code.

bEOE: End of enumeration was reached. During the first attempt to read a non-existing entry this output is set to TRUE. This means that read entries are valid if bEOE = FALSE and bError = FALSE

nFindFiles: Number of valid files in the buffer.

 

Example:

See: Example: File search (FB_EnumFindFileEntry, FB_EnumFindFileList).

 

Requirements

Development Environment

Target System

PLC LIbraries to include

TwinCAT v2.10.0 Build > 1302

PC or CX (x86)
CX (ARM)

TcUtilities.Lib