<< back to sysax.com Product page

10.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.

Exhibit 10.1. Syntax of command for opening local files

fileopen <keywords: read, write, append>, <name string>;

Exhibit 10.2. Examples for using the command for opening local files

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.

Exhibit 10.3. Syntax of command for closing local files

fileclose;

Exhibit 10.4. Example for using the command for closing local files

fileclose; #close the file