TwinCAT 3 PLC Lib: Tc2_System

FB_FileDelete

The function block deletes a file from the data storage device.

 

VAR_INPUT

VAR_INPUT
    sNetId    : T_AmsNetId;
    sPathName : T_MaxString;(* file path and name *)
    ePath     : E_OpenPath := PATH_GENERIC;
    bExecute  : BOOL;
    tTimeout  : TIME := DEFAULT_ADS_TIMEOUT;
END_VAR

sNetId: String containing the AMS network identifier of the target device to which the ADS command is directed (type: T_AmsNetId).

sPathName: File name, including the full path (type: T_MaxString).

ePath: This input can be used to select a TwinCAT system path on the target device for opening the file (type: E_OpenPath).

bExecute: The function block is activated by a rising edge at this input.

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

 
 

VAR_OUTPUT

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

bBusy: When the function block is activated, this output is set to TRUE and remains set until feedback is received. As long as bBusy is TRUE, no new command can be executed.

bError: If an error occurs during command execution, this output is set, once the bBusy output has been reset.

nErrId: Returns the ADS error code or the command-specific error code when the bError output is set.

Command-specific error code
Possible cause
0x70C
File not found. Invalid sPathName or ePath parameter.
 
 

Example of calling the function block in FBD:

PROGRAM Test
VAR
    fbFileDelete     : FB_FileDelete;
    bFileDelete      : BOOL;
    bFileDeleteBusy  : BOOL;
    bFileDeleteError : BOOL;
    nFileDeleteErrId : UDINT;
END_VAR
 
 

Requirements

Development environment
Target system type
PLC libraries to include (Category group)
TwinCAT v3.1.0
PC or CX (x86, x64, ARM)
Tc2_System (System)