Reading and
writing to files
The idea of random access
One advantage of storing your work on discs, rather than on a
cassette, is that it is much easier for the computer to find quickly
a particular item — just as it's much easier to move straight to a
particular track on a record than it is on a cassette. Tape storage
systems are called serial-access devices: they have to go right
through the tape serially (in sequence) to find what they are
looking for. Disc systems, such as your Econet file server, can
move straight to the item they want, and are called random-
access devices.
As well as making saving and loading operations faster, this
random-access feature allows you to select a particular section
within a file, and read or write to it immediately. The process is
called random-access reading and writing.
Opening a file
To use random access to a file, you:
■
say which file you are interested in
■
say whether you want to read or write to it or both
■
ask the filing system to give you a channel number, by
which you will communicate with the file.
All three operations are carried out in one command line.
EXAMPLE
X=OPENOUT("CALENDAR")
This means:
■
create and open a file called CALENDAR
■
open it for both reading and writing
■
give it a channel number, and let the variable X stand for
that channel number.
39