Open a low level file
The FOPEN() function in the
example below opens an existing file and returns a file handle.
It will return -1 if it cannot open the file so a real application
must always check that the function has succeeded:
lnFileHandle =
FOPEN
('fred.txt')
FWRITE
(lnFileHandle, 'Hello world')
FCLOSE
(lnFileHandle)
By default FOPEN() will create
a file with Read-only access. You can still try to write data
to the file with
FWRITE()
but no data will be written and no error will be raised.
You can pass a second parameter to the function and force the file
to be Read/Write or Write Only.
Be careful.
The numeric codes for this function are not the same as the codes for the
FCREATE() function.
Warning
You will be overwriting the contents of a file that
you have opened with FOPEN().
If you want to append to the file then you have to read the
original contents of the file into memory, add to that string
and write the modified string back to the file.
|