FB_FileRename

FB_FileRename 1:

The function block FB_FileRename can be used to rename a file.

FB_FileRename 2:

This function block is only suitable for logging in real-time to a limited extent.
For good performance, we recommend using the TF3500 TwinCAT Analytics Logger product, which is subject to a charge.

FB_FileRename 3: Inputs

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

Name

Type

Description

sNetId

T_AmsNetId

String containing the AMS network ID of the target device to which the ADS command is addressed (type: T_AmsNetId).

sOldName

T_MaxString

Old file name (type: T_MaxString)

sNewName

T_MaxString

New file name (type: T_MaxString)

ePath

E_OpenPath

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

bExecute

BOOL

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

tTimeout

TIME

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

FB_FileRename 4: Outputs

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

Name

Type

Description

bBusy

BOOL

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

BOOL

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

nErrId

UDINT

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 sOldName, sNewName or ePath parameter.

Example of calling the function block in FBD:

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

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)