The FREADBYKEY intrinsic is recommended for retrieving records
randomly. The desired key value and the key
location are specified in the intrinsic parameters. The index
of the specified key is checked for a matching key value and the
appropriate record is read.
If an exact key value match is not found, an error condition is returned.
Because of this, the FREADBYKEY intrinsic is not appropriate when
searching for an approximate key value or the lowest value of a key. Use the
FFINDBYKEY intrinsic in such cases.
Figure 5-4 Accessing a Record by Key Value
Records can also be accessed randomly using the FFINDN intrinsic. To
use this intrinsic, however, you need to know the record's relative record
number in its key sequence.
The FREADDIR intrinsic reads a single record based on its physical
record number in the file. The record number is supplied as parameter
data in the intrinsic call. Record numbering starts with either
1 or 0, depending on the specifications made when the file was built.
The FPOINT and FREADC intrinsics can be used to read a record
based on its physical record number. The FPOINT intrinsic positions
the pointers to the record identified by its physical record number in the
file. The FREADC intrinsic is then used to read the record based on
the physical record pointer without reference to the record's index location.
In this case, the FREAD intrinsic could also be used to read the
record, because the FPOINT intrinsic also sets the logical record
pointer to the record that it located by physical record number. By default,
the key used is the primary key for that record. An alternate key
is used, however, if such a key was specified by a previous call
to the FFINDBYKEY or FREADBYKEY intrinsic.
NOTE: This is true for the reads on the previous examples of
FFINDNFFINDBYKEY, FREADBYKEY intrinsics that sets
the key of reference for succeeding reads.