Returns information about an open file.
$fopen(name | N)
$fopen has the following properties:
|fname||returns the full path and file name assigned to the specified name / number.|
|pos||returns the position of the pointer (after what byte it is).|
|eof||returns 1 if end of file is reached, else 0.|
|err||returns 1 if an error occurred, else 0.|
Note that the .eof and .err properties should be checked after each file access command or identifier, since file access errors will not halt a script.
We have the following file called moo.txt in our mircdir:
one two three
At first, we open it using fopen moo moo.txt.
echo -a $fopen(moo).fname
echo -a $fopen(moo).err
This example returns 0 as no error occurred.
; echo the current position of the pointer echo -a $fopen(moo).pos ; this would echo 0, as it is at the begin of the file ; now let's read a line to move the pointer echo -a $fread(moo) ; echo the new position of the pointer echo -a $fopen(moo).pos ; as the pointer was moved, it will now return 5 (it was moved 5 bytes) ; the first three bytes are obvious (o, n, e), then there is a $cr, at the end of the line a $lf