file. Some well-written relative file programs are able
to
find and read the record
of
one
desired person out
of
a thousand
in
under
15
seconds, a feat no sequential
fiJe
program
could match.
FILE LIMITS
With relative files,
yOel
don't
have to worry about exactly where on the diskette's
surface a given record will
be
stored. or whether
it
will
fit
properly within the current disk
sector,
or
need to be extended onto the next available sector. DOS takes care
of
all that for
you. All you need
to
do
is
specify how long each record is,
in
bytes, and how many
records you will need. DOS will do the rest, and organize things
in
such a way that
it
can
quickly find any record
in
the file,
as
soon
as
it
is
given the record number (ordinal
position within the file).
The only limit that will concern you
is
that each record must be the same size, and the
record length you choose must
be
between 2 and 254 characters. Naturally the entire file
also has to
fit
on your diskette too. which means that the more records you need, the
shorter each record must be.
CREATING A RELATIVE FILE
When a relative file
is
to
be used for the first time, its Open statement will create the
file; after that, the Open statement
is
used
to
reopen the file for both reading and writing.
FORMAT STATEMENT TO OPEN A RELATIVE FILE:
BASIC 7.0: DOPEN
# file
#.
"file
name",
L record length l.Ddrive
#1
[,Udevice
#1
BASIC 2.0: OPEN
file
#.
device
#.
channel
#,
"drive
#:
file name,
L."
+ CHR$
(record length)
where "file
#"
is
the
file
number, normally
an
integer between I and 127: "device
#"
is
the device number to
be
used. normally 8 on the 1571; "channel
#"
selects a particular
channel along which communications for this
file
can take place, normally between 2 and
14;
"drive
#"
is
the drive number. always 0 on the 1571; and "file
name"
is
the name
of
the file, with a maximum length
of
16
characters. Pattern matching characters are allowed
in
the name when accessing
an
existing file. but not when creating a new one. The record
length
is
the size
of
each record within the
file
in
bytes used, including carriage returns.
quotation marks and other special characters.
54