|
Type
| Function block |
|
Description
| Moves the current file pointer to a new position.Assign the valid handle of the file to be processed to the HANDLE input. This handle is created when the file is opened with the FILE_OPEN_2 function block. Write the relative offset to be used to move the file pointer to the OFFSET input. Enter the reference to be used to move the pointer at the MODE input (see description of the MODE input).As soon as the REQ input is set to TRUE, the inputs are validated. The REQ input must remain set to TRUE, until the file seek operation is completed (regardless of whether the operation succeeded or failed). The BUSY output is TRUE while the operation is being executed asynchronously on a Service Thread. Execution of the function block is complete when the DONE output is set to TRUE. If an error occurred during execution, ERROR is set to TRUE, and the error code can be read from the STATUS output. |
|
Notes
|
- The status of the DONE, BUSY, ERROR, and STATUS outputs are maintained as long as REQ is TRUE.Do not reset the REQ input until the FB is finished by setting the DONE state. Resetting the REQ input will result in resetting the outputs to their default values.
- Specifying a position beyond the end of file is possible. If the position is written, the gap between the end of file and the current writing position is filled with zeros.
- When the function block is used as global function block, it is not thread-safe. In this case, make sure to prevent concurrent calls (e.g., by using the MUTEX function block).
- Function blocks have to be instantiated. The instance name of the function block has to be declared in the 'Variables' table of the POU where the FB is going to be used. The instance name must be unique within the POU.
|
|
Parameters
| Inputs
REQ
| Data type: | BOOL |
| Description: | As soon as the input is set to TRUE, the inputs are validated. Must remain set to TRUE until the file operation is complete. Once the operation is fully complete, the input must be set to FALSE. Subsequently, the outputs are reset to their default values. |
HANDLE
| Data type: | UINT |
| Description: | File handle of the file in which the position is to be set. |
OFFSET
| Data type: | ANY_INT |
| Description: | New position in file. |
MODE
| Data type: | FILE_SEEK_MODE |
| Description: | Positioning mode
| 0 | The search for the new position begins at the start of the file. |
| 1 | The search for the new position begins at the current position of the file. |
| 2 | The search for the new position begins at the end of the file. |
|
Outputs
DONE
| Data type: | BOOL |
| Description: | Set to TRUE when the operation has been completed successfully. |
BUSY
| Data type: | BOOL |
| Description: |
| 0 | No operation executed on Service Thread. |
| 1 | The file seek operation is currently being executed asynchronously on Service Thread. |
|
ERROR
| Data type: | BOOL |
| Description: |
| 0 | No error occurred when setting the position. |
| 1 | An error occurred when setting the position. The error code can be read from the STATUS output. |
|
STATUS
| Data type: | DWORD |
| Description: | Indicates the status of the operation:
| 0 | No errors during execution of the file operation. |
| 1 | The execution of the file operation has failed. |
| 12 | An invalid file handle was specified. |
| 14 | An invalid offset was specified. |
| 16 | An invalid seek mode was specified. |
|
POSITION
| Data type: | UDINT |
| Description: | New position of the file pointer. |
|