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.

Important note:

A new search may be started only if the previous search has been fully completed. The function block instance 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.

FB_EnumFindFileList 2: Inputs

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

Name

Type

Description

sNetID

T_AmsNetID

A string with the network address of the TwinCAT computer on which a directory search is to be executed can be specified here. For the local computer an empty string may be specified.

sPathName

T_MaxString

A 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

E_EnumCmdType

eEnumCmd_First adds the first data field to the buffer, eEnumCmd_Next adds the next data field. No other parameter values are used.

pFindList

ST_FindFileEntry

Address (pointer variable) of an array variable

cbFindList

ST_FindFileEntry

Byte size of array variable

bExecute

BOOL

The function block is enabled by a positive edge at this input.

tTimeout

TIME 

States the length of the timeout that may not be exceeded by execution of the ADS command.

FB_EnumFindFileList 3: Outputs

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

Name

Type

Description

bBusy

BOOL

When the function block is enabled, this output is set and remains set until a feedback is received.

bError

BOOL

If an error occurs during the transmission of the command, this output is set after the bBusy output is reset.

nErrId

UDINT

Returns the ADS error number when the bError output is set.

bEOE

BOOL

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 as long as bEOE = FALSE and bError = FALSE.

nFindFiles

UDINT

Number of valid entries in the buffer.

Example:

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

Requirements

Development environment

Target platform

PLC libraries to be integrated (category group)

TwinCAT v3.1.0

PC or CX (WES7/Win7/Win10: TC RT x86/x64, WEC6/7: TC RT x86, WEC7: TC CE7 ARMV7, TC/BSD: TC RT x64, TC OS ARMT2)

Tc2_Utilities (System)