Direct access files are structured binary files, in which is it possible to go directly to a desired record.
To enable this, a file index is used.
When it can be manipulated:
An example program shows the use of a direct access file in a program dealing with bank accounts. A direct access file is appropriate here because only one of the many records in the file is updated.
I/O library instantiation
variable definition
procedures and functions that use the file index:
relative to index:
SET_INDEX (accfile, recordnum);
WRITE (accfile, rec);
specific location:
WRITE (accfile, rec, recordnum);
file index is automatically incremented after I/O
while INDEX(accfile) <= 100 loop
READ (accfile, rec);
end loop;