FileSeek
Description
This function block sets the current position in an open file.
Figure 7-213: The FileCopy Function Block
Related Functions
FileClose, FileEOF, FileOpenA, FileOpenR, FileOpenW, FileReadLine, FileReadBinData, FileWriteBinData, FileWriteLine
See also: File Management
Arguments
Input
Execute | Description | On the rising edge A rising edge is the transition of a digital signal from low to high. It is also called positive edge test if the end of the file is reached in a file that is open for reading. |
Data Type | BOOL | |
Range | 0, 1 | |
Unit | N/A | |
Default | — | |
ID | Description | ID of the open file. |
Data Type | UDINT | |
Range | N/A | |
Unit | N/A | |
Default | — | |
POS | Description | Number of bytes to offset from ORG.
|
Data Type | DINT | |
Range | N/A | |
Unit | N/A | |
Default | — | |
ORG | Description | Origin of the move.
|
Data Type | DINT | |
Range | SEEK_SET, SEEK_CUR, SEEK_END | |
Unit | N/A | |
Default | — |
Output
Done | Description | If TRUE, then the command completed successfully |
Data Type | BOOL | |
Error | Description | If TRUE, an error has occurred |
Data Type | BOOL | |
ErrorID | Description | Indicates the error if Error output is set to TRUE. See the table in Search IndexFile and TCP/IP Function Block ErrorID Output |
Data Type | DINT |
Example
Structured Text
(* FileSeek example *)
CASE StepCounter OF
0:
(* Move to beginning of the file *)
Inst_FileSeek(TRUE, MyInputFileID, 0, SEEK_SET);
StepCounter := StepCounter + 1;
1:
Inst_FileSeek(TRUE, MyInputFileID, 0, SEEK_SET);
IF Inst_FileSeek.Done THEN
Inst_FileSeek(FALSE, 0, 0, SEEK_SET);
StepCounter := StepCounter + 1;
END_IF;
END_CASE;