FB_FileRename

FB_FileRename 1:

With this function block the existing file can be renamed.

VAR_INPUT

VAR_INPUT
    sNetId      : T_AmsNetId;
    sOldName    : T_MaxString;
    sNewName    : T_MaxString;
    ePath       : E_OpenPath := PATH_GENERIC;      (* Default: generic file path*)
    bExecute    : BOOL;     
    tTimeout    : TIME;
END_VAR

sNetId    : Is a string containing the AMS network identifier of the target device to which the ADS command is directed.

sOldName : Contains the old path and filename for the file to be renamed.

sNewName : Contains the new path and filename for the file to be renamed.

ePath :  The variable of this type selects generic or one of the TwinCAT system paths on the target device to perform the file open operation.

bExecute    : The ADS command is triggered by a rising edge at this input.

tTimeout    : States the time before the function is cancelled.

VAR_OUTPUT

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

bBusy:    This output remains TRUE until the block has executed a command, but at the longest for the duration supplied to the ‘tTimeout’ input. While bBusy = TRUE, no new command will be accepted at the inputs. Please note that it is not the execution of the service but its acceptance whose time is monitored.

bError:    This output is switched to TRUE if an error occurs during the execution of a command. The command-specific error code is contained in ‘nErrId’.

nErrId:    Contains the command-specific ADS error code of the most recently executed command.

 

Function specific ADS error code

Possible reason

0x70C

File not found. Invalid sOldName, sNewName or ePath parameter.

 

Example of calling the block in FBD:

PROGRAM Test
VAR
    fbFileRename    : FB_FileRename;
    bFileRename     : BOOL;
    bFileRenameBusy : BOOL;
    bFileRenameError: BOOL;
    nFileRenameErrId: UDINT;
END_VAR

FB_FileRename 2:

Requirements

Development environment

Target system type

PLC libraries to include

TwinCAT v2.8.0

PC or CX (x86)

TcSystem.Lib

TwinCAT v2.10.0 Build >= 1301

CX (ARM)

TcSystem.Lib