System information
FUNCTION 36: SET RANDOM RECORD
Entry Parameters:
Register C: 24H
Registers DE: FCB Address
Returned Value:
Random Record Field Set
The Set Random Record function causes the BDOS automatically to produce the random record
position from a file that has been read or written sequentially to a particular point. The function
can be useful in two ways.
First, it is often necessary initially to read and scan a sequential file to extract the positions of
various key fields. As each key is encountered, Function 36 is called to compute the random
record position for the data corresponding to this key. If the data unit size is 128 bytes, the
resulting record position is placed into a table with the key for later retrieval. After scanning the
entire file and tabulating the keys and their record numbers, the user can move instantly to a
particular keyed record by performing a random read, using the corresponding random record
number that was saved earlier. The scheme is easily generalized for variable record lengths,
because the program need only store the buffer-relative byte position along with the key and
record number to find the exact starting position of the keyed data at a later time.
A second use of Function 36 occurs when switching from a sequential read or write over to
random read or write. A file is sequentially accessed to a particular point in the file, Function 36
is called, which sets the record number, and subsequent random read and write operations
continue from the selected point in the file.
5.2 Call Conventions CP/M Operating System Manual
5-34