Random Access
After you open a file for input, the first Read or Readln statement will begin reading at the beginning of the file. Each subsequent Read or Readln will continue where the last read finished. In this way, you can progress through the file from start to finish. Similarly, when a file is opened for output, data is always appended to the end of the last data that was written to the file.
The DataFlex Set_Channel_Position command allows you to explicitly specify an offset from the beginning of the I/O file where the next read or write operation will occur. The syntax of the Set_Channel_Position command is:
Set_Channel_Position {channel-num} To {offset}
Where:
- {channel-num} is the channel assigned to the file that you are reading or writing.
- {offset} is the number of bytes from the beginning of the file where the next I/O operation will occur.
An offset value of 1 specifies that the next I/O operation will occur at the first byte (i.e., the {offset} parameter is not zero-based). An offset value of -1 specifies that the next I/O operation will occur at the end of the file.
Refer to the Set_Channel_Position and Get_Channel_Position commands in the Language Reference for more information.