Function BlockFileReadLinePLCopen motion icon

Description

This function block reads a string value from a file. FileReadLine stops reading from the file if 255 characters are read (the maximum length of the STRING type) or if a new line is encountered.

Figure 7-210: The FileReadLine Function Block

Related Functions

FileClose, FileEOF, FileOpenA, FileOpenR, FileOpenW, FileReadBinData, FileSeek, FileWriteBinData, FileWriteLine

See also: File Management

Arguments

Input

Execute Description On the rising edgeClosedA rising edge is the transition of a digital signal from low to high. It is also called positive edge read the size of a file.
  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

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
Value Description The string value read from the file.
  Data Type STRING

Example

Structured Text

(* FileReadLine example *)
CASE StepCounter OF
0:
  Inst_FileReadLine(TRUE, MyInputFileID);
  StepCounter := StepCounter + 1;
1:
  Inst_FileReadLine(TRUE, MyInputFileID);
  IF Inst_FileReadLine.Done THEN
     lineText := Inst_FileReadLine.Value;
     Inst_FileReadLine(FALSE, 0);
     StepCounter := StepCounter + 1;
  END_IF;
END_CASE;