FileOpenR
Description
This function block opens a file for reading.
Files must be closed using the FileClose function block.
-
- The controller allows only 32 open files at any given time.
Figure 7-208: The FileOpenR function block
Related Functions
FileClose, FileEOF, FileOpenA, FileOpenW, FileReadLine, FileReadBinData, FileSeek, FileWriteBinData, FileWriteLine
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 request to open a file |
Data Type | BOOL | |
Range | 0, 1 | |
Unit | n/a | |
Default | — | |
Path | Description | The path of the file to open or create. |
Data Type | STRING | |
Range | n/a | |
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 | |
ID | Description | ID of the open file. |
Data Type | UDINT |
Example
Structured Text
(* FileOpenW example *)
(* Replace FileOpenW with FileOpenA or FileOpenR as needed*)
CASE StepCounter OF
0:
Inst_FileOpenW(TRUE, 'Results.txt');
StepCounter := StepCounter + 1;
1:
Inst_FileOpenW(TRUE, 'Results.txt');
IF Inst_FileOpenW.Done THEN
ResultsFileID := Inst_FileOpenW.ID;
Inst_FileOpenW(FALSE, '');
StepCounter := StepCounter + 1;
END_IF;
END_CASE;