Function Description

The SEEK_FILE function sets the current position in the file at the position specified by the Offset argument.

The Whence argument assigns the file position pointer. It has three values:

  • SEEK_SET (value 0): this places the pointer at the position corresponding to the offset (default value : to overwrite the file),

  • SEEK_CUR (value 1): places the pointer at the current position + offset,

  • SEEK_END (value 2): places the pointer at the position corresponding to the file size + offset. Useful if you want to overwrite last variables of the file (negative offset) or to write in the file from the end in order to not overwrite data.

The following figure illustrates the positioning of the pointer according to the offset: (differents values of offset in this diagram).

The additional parameters EN and ENO can be configured.

FBD Representation

The representation in FBD of the SEEK_FILE function is as follows:

Ladder Representation

The representation in Ladder of the SEEK_FILE function is as follows:

IL representation

Representation:

CAL SEEK_FILE_Instance (REQ:=SeekFileStart, FILEDESC:=SeekFileDescriptor, OFFSET:=SeekFileOffset, WHENCE:=SeekFileWhence, DONE=>SeekFileDone, ERROR=>SeekFileError, STATUS=>SeekFileStatus)

ST representation

Representation:

SEEK_FILE_Instance (REQ:=SeekFileStart, FILEDESC:=SeekFileDescriptor, OFFSET:=SeekFileOffset, WHENCE:=SeekFileWhence, DONE=>SeekFileDone, ERROR=>SeekFileError, STATUS=>SeekFileStatus);

Parameter Description

The following table describes the input parameters:

Parameter

Type

Comment

FILEDESC

DINT

This parameter specifies the file descriptor returned by the CREATE_FILE or OPEN_FILE functions.

OFFSET

DINT

This parameter specifies the offset of the movement.

WHENCE

INT

Seek Mode:

  • SEEK_SET (0) - set to Offset,

  • SEEK_CUR (1) - set to the current position plus Offset,

  • SEEK_END (2) - set to the file size plus Offset.

Description of common parameters.