Function Description

The RD_FILE_TO_DATA function allows data to be read from a file, at the current position of the file, and enables it to be copied into a direct address variable (%MW1000), a located variable (VAR0 @ %MW1000), or an unlocated variable. After reading, the current position in the file is updated.

This elementary function reads a number of bytes that correspond to the size of the variable in the specified file.

The additional parameters EN and ENO can be configured.

FBD Representation

The representation in FBD of the RD_FILE_TO_DATA function is as follows:

Ladder Representation

The representation in Ladder of the RD_FILE_TO_DATA function is as follows:

IL representation

Representation:

CAL RD_FILE_TO_Instance (REQ:=ReadFileToDataStart, FILEDESC:=ReadFileToDataDescriptor, DONE=>ReadFileToDataDone, ERROR=>ReadFileToDataError, STATUS=>ReadFileToDataStatus, VARIABLE=>ReadFileToDataVariable, NBBYTESRD=>ReadFileToDataNumberBytesReadStatus)

ST representation

Representation:

RD_FILE_TO_Instance (REQ:=ReadFileToDataStart, FILEDESC:=ReadFileToDataDescriptor, DONE=>ReadFileToDataDone, ERROR=>ReadFileToDataError, STATUS=>ReadFileToDataStatus, VARIABLE=>ReadFileToDataVariable, NBBYTESRD=>ReadFileToDataNumberBytesReadStatus);

Parameter Description

The following table describes the input parameters:

Parameter

Type

Comment

FILEDESC

DINT

This parameter specifies the file descriptor returned by the CREATE_FILE or OPEN_FILE functions.

The following table describes the output parameters:

Parameter

Type

Comment

VARIABLE

ANY

This parameter specifies the variable or table which will receive the data.

Any direct address variable (%MW1000), located variable (VAR0 @ %MW1000), or unlocated variable (single type, table, structure) can be used as a destination.

To copy to a table or direct variables, the syntax used is %MW1000:10 (10 words starting at %MW1000).

NBBYTESRD

UDINT

This parameter specifies the size effectively read. It may be smaller than the size of the variable.The main reason why the NBBYTESRD can be smaller than the Variable size is that:

File size- read start position < Variable size

Then the read variable is only updated with the number of bytes read and the other bytes of data come from the last reading.

Description of common parameters.