ChaDter
7
DISK
FILES
You may want
to
store data on disk for future use. To do this,
you need to store the data in a
file.
A file is an organized collec-
tion
of
related data.
It
may contain a mailing list, a personnel
record, or almost any kind
of
information.
You access this information in
records.
A record
is
a small por-
tion of data from the disk file such as a name and address in a
mailing list file.
A
record is the largest block
of
information that
you can address with a single command.
With BASIC you can create and access
2
types
of
files: sequen-
tial access or direct access.
Sequential Access Files
With sequential access files, you can access data only in the
same order as it was originally stored. To read from or write to a
particular section in the file, you must first read through all the
records in the file from the beginning until you get to the de-
sired record.
Data is stored in a sequential access file as ASCII characters.
Therefore,
it
is ideal for storing free-form data without wasting
space between data items. However,
it
is limited in flexibility
and speed.
The statements and functions used with sequential files are:
WRITE
#
LOC EOF OPEN
PRINT# INPUT#
LOF
CLOSE
PRINT USING
#
LINE INPUT#
These statements and functions are discussed in more detail in
Chapter
10.
67