fid = Open(filename [,mode])
Opens a file in the mode specified by the optional string, mode. It returns a new file handle or nil.
filename |
A string specifying the full path qualified filename. |
mode (optional) |
A string specifying the mode in which to open. See the table below for options. |
fid |
A handle to the file that can be used for subsequent operations on the file. It is set to nil on failure. |
r |
Read (default). |
w |
Write. |
a |
Append. |
r+ |
Read update mode. All previous data is preserved. |
w+ |
Write update mode. All previous data is erased. |
a+ |
Append update mode. Writing is only allowed at the end of the file. |
The following opens an existing file for reading and stores the returned file handle in fid:
> fid = Open(‘c:/test.txt’,’r’) // Note the use of forward slash
Close(filehandle)
filehandle::close()
Closes the specified file and returns true on success.
filehandle A handle to a file currently open. This is obtained when the file is opened.
The following closes the file opened in the above example using the second method:
> Close(fid) // or equivalently fid::close()