File Pointers
As you read and write data you move through a file. For each opened channel PRO/5 remembers the current position within the file opened on that channel. This is a file pointer. The file pointer remembers the index of the current record (or byte for byte files). For infinite files, the current index is always zero. The IND() function may be used to determine the current position within the file.
If the file pointer points past the last record/byte in the file, it is at end-of-file. Attempts to read data at the end-of-file will result in an error. Attempts to write at end-of-file may cause an error, depending on the type of file.
When a channel is opened, the file pointer is automatically set to the first logical record or byte in the file. For keyed files this would be the record with the lowest key. If a file has no records (such as an empty KEYED file or SERIAL file), the pointer is set to the end-of-file.
All data transfers take place at the current position within the file. The program may move the file pointer to control where each data transfer will take place. Usually, PRO/5 will automatically bump the file pointer to the next logical record/byte in the file after each transfer. Therefore, if the program does not explicitly position the file pointer, successive data transfers will step sequentially through the file. The IND= and KEY= options on the READ and WRITE verbs control positioning in the file. The DIR= option may optionally control the direction and magnitude of movement in a file following successful operations.