Basic Disk Operating System (EDOS) Functions
4-28
SET
RANDOM
RECORD
ENTRY
CL: 24H
DX: FCB
Offset
FUNCTION
36
SET
RANDOM
RECORD
RETURN
Random
Record
Field Set
The
Set
Random
Record function returns the
random
record position
of
the next
record
to
be accessed from a file which has been read
or
written sequentially
to
a
particular point. The function can be useful in two ways.
First, it
can
be used
to
create a table
of
key field values
and
the corresponding record
addresses.
It
is often necessary
to
first 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 minus one is placed into a
table with the key for later retrieval. After scanning the entire file
and
tabularizing
the keys
and
their record numbers, programs can move instantly
to
a particular
keyed record by performing a
random
read using the saved
random
record number.
The
scheme is easily generalized when variable record lengths are involved since the
program
need only store the buffer-relative byte position along with the key
and
record
number
in
order
to find the exact starting position
of
the keyed
data
at
a later
time.
A second use
of
function 36 occurs when switching from sequential read
(or
write)
to
random
read
(or
write). A file
is
sequentially accessed
to
a particular point,
function 36
is
called
to
set the record number,
and
subsequent
random
read
(write)
operations continue from the next record in the file.