OPEN_FILE
Function Name |
OPEN_FILE |
---|---|
Description |
Opens a file on disk in 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). |
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). 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 function in ST Programs.
Example:
ST Program - OPEN_FILE:
To use an OPEN_FILE function in an ST program, you need to use this syntax:
- FileNumber := OPEN_FILE( FILENAME, APPEND );
Where FileNumber, FILENAME, and APPEND are variables that are declared earlier in the ST program. The FILENAME variable has to be a string and the APPEND variable has to be a Boolean. The FileNumber variable will be used to store the FileID that is returned when the specified file is opened.