FileReadLine

PLCopen motion icon

 Function BlockClosed A function block groups an algorithm and a set of private data. It has inputs and outputs. - Reads a string value from a text file.

Inputs

Input

Data Type

Range

Unit

Default

Description

Execute

BOOL

0, 1

N/A

No default

On the rising edgeClosed The transition of a digital signal from low to high. AKA: positive edge., read the size of a file.

ID

UDINT

N/A

N/A

No default

The ID of the open file.

Outputs

Output

Data Type

Range

Unit

Description

Done

BOOL

 

 

If TRUE, the command completed successfully.

Error

BOOL

 

 

If TRUE, an error has occurred.

ErrorID

DINT

 

 

Indicates the error if Error output is TRUE.

See the table in Search IndexFile and TCP/IP Function Block ErrorIDs.

Value

STRING

 

 

The string value read from the file.

Remarks

FileReadLine stops reading from the file if either:

  • 255 characters are read (the maximum length of the STRING type).
  • A new line is encountered.

Figure 1: FileReadLine

FBD Language Example

Not available.

FFLD Language Example

Not available.

IL Language Example

Not available.

ST Language Example

(* 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;

See Also