You are here: Core Reference > Coding > Logic > OPEN_FILE_EX

OPEN_FILE_EX

Function Name

OPEN_FILE_EX

Description

Opens a file on disk in binary or text mode. The file can be used to store a value, text etc. When a file has been opened, data can be written to it by using the WRITE_FILE function (see WRITE_FILE) or WRITE_FILE_BYTE function (see WRITE_FILE_BYTE).

Arguments

FILENAME {STRING}

The FILENAME string defines the name of the file that is to be opened.

APPEND {BOOL}

Controls whether data is added to the end of the file (True) or the existing data is overwritten (False).

BINARY {BOOL}

Controls whether the file is opened in text mode (False) or binary mode (True).

For more information on the data types for the inputs and outputs, see Data Type Hierarchy.

Returns

FileID {UDINT}

Returns the FileID of the file. The FileID is used to identify the file when writing and closing.

NOTE: You should only use the OPEN_FILE_EX function in ST Programs.

Example:

ST Program - OPEN_FILE_EX:

To use an OPEN_FILE_EX function in an ST program, you need to use this syntax:

  • FileNumber := OPEN_FILE_EX( FILENAME, APPEND, BINARY );

Where FileNumber, FILENAME, APPEND, and BINARY are variables that are declared earlier in the ST program. The FILENAME variable has to be a string, and the APPEND and BINARY variables have to be Booleans. The FileNumber variable will be used to store the FileID that is returned when the specified file is opened.


ClearSCADA 2015 R2