Definition

The EFB WR_DATA_TO_FILE and RD_FILE_TO_DATA allow variables to be written into a file and data in a file to be read. These elementary functions make up part of the basis of file management and can therefore be used to build whatever type of application that requires these functions.

The example only uses the following four functions:

  • OPEN_FILE, to open an already created file,

  • WR_DATA_TO_FILE, to write data,

  • RD_FILE_TO_DATA, to read data,

  • CLOSE_FILE to close the file.

Declaration of Variables

The table below shows the details of the variables to be declared for the parameters used:

Name of the variable.

Type

Comment

cmd_open

EBOOL

File opening bit.

cmd_write

EBOOL

Write data to file bit.

cmd_read

EBOOL

Read file data bit.

cmd_close

EBOOL

Close file bit.

FileName

STRING

File name. By default the value is ‘test’:

FileDesc

INT

FileDesc is the number automatically assigned when a file is opened. This unique and temporary identification number will be assigned by the OPEN_FILE function.

NOTE: The temporary identification number FileDesc enables, amongst other things, several people to open the same file at the same time to work on it. The number used for FileDesc is freed once the file is closed using the CLOSE_FILE function. FileDesc is managed automatically by the system.