IBM 5110 User Manual page 154

Apl
Table of Contents

Advertisement

Direct Access Files
Since sequential processing can be time consuming, it would be
helpful if diskette records were available like books in a library. That
is, you could go to an index, find the location where the book is
stored, go to the right shelf, and get the book you want. No one
would read all the books in the shelves before reading the desired
book. Likewise, it would be desirable to skip the records not needed
in a job and process only the desired ones. Because direct access
files allow specified records to be processed by record number, the
limitation of sequential processing can be overcome by an index.
To create and use an index, you could use the following procedure:
1.
As you create the direct access, you also create a matrix with
each row representing a key field in the record. For example, the
first 7 characters in a record are the item number. As you write
a record to the file, you also add the item number to a matrix of
item numbers.
2.
Now, when you want to directly access a record by record
number, you can find the record number by using the following
user-defined function (assuming 010+0):
VZ~LIST
INDEX ITEM
I::
:1.::1
Z
~
.. ( ( LIB T
I ... • :::: ( ...
:I. t
f:i
LIS T )
tIT E r1 ) ) /
l.
:I.
t
(oi
I... 1ST
V
The explicit result of this user-defined function is the row of the
matrix that contains the specified item number. This explicit
result also identifies the record number of the specified item
number in the data file.
3.
Once you find the record number of the specified item number,
you can directly access and process that record without regard to
its relation to other records.
Input/Output Control
149

Advertisement

Table of Contents
loading

Table of Contents