The POINT_LUN procedure sets or obtains the current position of the file pointer for the specified file.
Note: POINT_LUN cannot be used with files opened with the RAWIO keyword to the OPEN routines. Depending upon the device in question, the IOCTL function might be used instead for files of this type.
Use Of POINT_LUN On Compressed Files
In general, it is not possible to arbitrarily move the file pointer within a compressed file (files opened with the COMPRESS keyword to OPEN) because the file compression code needs to maintain a compression state for the file that includes all the data that has already been passed in the stream. This limitation results in the following constraints on the use of POINT_LUN with compressed files:
- POINT_LUN is not allowed on compressed files open for output, except to positions beyond the current file position. The compression code emulates such motion by outputting enough zero bytes to move the pointer to the new position.
- POINT_LUN is allowed to arbitrary positions on compressed files opened for input. However, this feature is emulated by positioning the file to the beginning of the file and then reading and discarding enough data to move the file pointer to the desired position. This can be extremely slow.
For these reasons, use of POINT_LUN on compressed files, although possible under some circumstances, is best avoided.
To move the file pointer 2048 bytes into the file associated with file unit number 1, enter:
POINT_LUN, 1, 2048
To return the file pointer for file unit number 2, enter:
POINT_LUN, -2, pos
POINT_LUN, Unit, Position
The file unit for the file in question. If Unit is positive, POINT_LUN sets the file position to the position given by Position. If negative, POINT_LUN gets the current file position and assigns it to the variable given by Position. Note that POINT_LUN cannot be used with the 3 standard file units (0, -1, and -2).
If Unit is positive, Position gives the byte offset into the file at which the file pointer should be set. For example, to rewind the file to the beginning, specify 0.
If Unit is negative, Position must be a named variable into which the current file position will be stored. The returned type will be a longword signed integer if the position is small enough to fit, and a 64-bit longword integer otherwise.
GET_LUN, OPENR/OPENU/OPENW, TRUNCATE_LUN