Previous | Next Table Of Contents > 5 Reading and writing local files > 5.1 Opening and closing local files5.1 Opening and closing local files
A file can be opened for reading or writing using the fileopen command. The predefined keywords read, write, and append are used to open the file for reading, writing, or appending. If the file is opened for writing, any existing file with the same name is deleted and a new file will be created. The name string specifies the name of the file to open. The fileresult predefined status flag is set to the predefined constant success if the command completed successfully.
The syntax is
| fileopen <keywords: read, write, append>, <name string>; |
|
Some examples are
| fileopen write, "error.txt"; #create or open a new file for writing
fileopen append, "output.txt"; #open a file to append data to the end of the file |
|
An opened file can be closed with the fileclose command. Since only one file can be opened at a time, no arguments are required.
The syntax is
Some examples are
| fileclose; #close the file |
|
Previous | Next