Format
number1 = FILEPOS (number2,number3) <--Format 1
number1 = FILEPOS (number2,EOF) <--Format 2
number1 = FILEPOS (number2,CURRENT) <--Format 3
Description
This statement is used to set or retrieve the read/write position for files
opened in Random mode. In all three formats, number2 is the file number of
the file. This file number must have been previously opened for Random
mode by the OPEN statement. Format 1 is used to set the current read/write
position of the file specified by number2. Number3 should be the offset
(in bytes) from the start of the file. Format 2 is used to set a
read/write position of a random file to the end of the file. Format 3 is
used to retrieve the current read/write position (as a byte offset from the
beginning of the file) of the file. In all cases, if an error occurs, the
system ERROR variable will be set. A list of these codes is contained in
the Error Codes Chapter of the ASIC Manual. If no error occurs, then
number1 will be set to the current read/write position of the file.
Example 1
A&=FILEPOS(1, 100)
This example assumes that file 1 was previously opened for RANDOM I/O using
the OPEN statement. After execution of this statement, the read/write
position of file number 1 will be set to 100. Subsequent PRINT #
statements would write to the file starting at position 101.
Example 2
A&=FILEPOS(1,EOF)
This example assumes that file 1 was previously opened for RANDOM I/O using
the OPEN statement. After execution of this statement, the read/write
position of file number 1 will be set to the end of the file. Subsequent
PRINT # operations to this file will result in data being appended to this
file.
Example 3
A&=FILEPOS(1,CURRENT)
This example assumes that file 1 was previously opened for RANDOM I/O using
the OPEN statement. After execution of this statement, the current
read/write position of file number 1 will retrieved and stored in A&. The
read/write position of file number 1 will NOT be altered after execution of
this statement.
Comments
If you wish to use this command with files larger than 32767 bytes, you
should use long integer or decimal numbers with this statement. If you set
the read/write position past the physical end of file and attempt to read
from the file, you will receive an error on the INPUT# command. If you set
the read/write position past the end of file and issue a PRINT# command,
the data will be correctly written at the position you specified.
See Also
-
OPEN
- INPUT#
- PRINT#
- CLOSE
- FILELEN
|