FB_FileSeek

FB_FileSeek 1:

The function block sets the file pointer of an open file to a definable position.

VAR_INPUT

VAR_INPUT
    sNetId    : T_AmsNetId;
    hFile     : UINT;
    nSeekPos  : DINT;(* new seek pointer position *)
    eOrigin   : E_SeekOrigin:= SEEK_SET;
    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).

hFile: File handle, which was generated when the function block FB_FileOpen was created.

nSeekPos: New position of the file pointer.

eOrigin: Relative position, to which the file pointer is to be moved (type: E_SeekOrigin).

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

0x703

Invalid or unknown file handle.

0x70E

File was opened with wrong method (e.g. with obsolete FILEOPEN function block).

Example of calling the function block in FBD:

PROGRAM Test
VAR
    fbFileSeek       : FB_FileSeek;
    hFile            : UINT;
    nSeekPos         : DINT;
    bFileSeek        : BOOL;
    bFileSeekBusy    : BOOL;
    bFileSeekError   : BOOL;
    nFileSeekErrorId : UDINT;
END_VAR
FB_FileSeek 2:

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)