CHAPTER 5 DISK FILE INPUT/OUTPUT
BASIC-SO
includes two types
of
disk file Input/Output operations: sequential and
random. Sequential
I/O
lets you read or write a file from the beginning to the end;
random
I/O
lets you specify where in the file you read or write.
Because
BASIC-SO
runs under ISIS-II and RMX/SO, filenames correspond to the
ISIS-II and RMX/80-DFS format (:Fn:name.ext, where n
is
the drive number).
BASIC-SO
also gives you access to disk file-handling commands:
DIR, which lists the files
on
a disk
RENAME, which changes the name
of
a disk file
A TTRIB, which changes the attributes
of
a disk file
KILL, which deletes a disk file (it
is
actually the system DELETE command,
but
the name must be different because
BASIC-SO
includes a DELETE command to
delete lines from a program).
For more information about ISIS-II filenames or operations,
see
the ISIS-II User's
Guide.
Although both sequential and random
I/O
allow you to create, read, and write files
on disk, sequential
I/O
is
somewhat simpler in concepts and operation.
If
you
haven't worked with disk files before, it would probably be better to start with
se-
quential
110
to learn the principles.

Sequential File

1/0

BASIC-SO
Sequential
I/O
allows you to build sequential data files containing
numbers and strings
of
up to
255
characters. In general, to use sequential
110
you
must open the file, execute a series
of
INPUT (to read) or PRINT (to write)
statements, then close the file.
A sequential file
is
open either for input or output. To switch from one to the other,
you must close the file and open it again with the opposite attribute. Any
110
opera-
tion that immediately follows
an
OPEN statement starts at the beginning of the file.
Opening a Sequential File
You open a sequential file with the OPEN statement.
It
specifies whether the file
is
to be opened for input or output, assigns it a file number, and specifies the filename.
Up to
six
files can be open
at
one time.
If
the file named in an OPEN statement that
specifies output does not exist, it
is
created. Once a file
is
open, it cannot be opened
again without closing it first.
If
you attempt to do so, an error message results.
To open an input file named :Fl:DATES and assign
it
file
number
1:
OPEN "1",#1,":F1:DATES"
5-1