Vector Basic Interpreter Basic 80 Reference Manual - page 147
10 ON ERROR
GOTO
2000
20 OPEN
"I", t 1, "NAMES'·
30 REM IF FILE
EXISTS,
WRITE
IT TO
'·COPY"
40 OPEN
II
0" ,
i 2 ,"COpy'·
50 IF EOF (1) THEN
90
60 LINE
INPUTi1,A$
70 PRINTt2,A$
80 GOTO
50
90 CLOSE
.1
100 KILL
-NAMES"
110 REM ADD NEW ENTRIES
TO FILE
120 INPUT
"NAME" ;N$
130 IF N$-""
THEN
200
'CARRIAGE
RETURN
EXITS
INPUT
LOOP
140 LINE
INPUT
"ADDRESS?
"iA$
150 LINE
INPUT
"BIRTHDAY?
"iB$
160 PRINTt2,N$
170 PRINTt2,A$
180 PRINTt2,B$
190 PRINT:GOTO
120
200 CLOSE
205 REM CHANGE
FILENAME
BACK TO
··NAMES"
210 NAME
"COpy" AS
"NAMES ,.
2000 IF ERR-53
AND ERL=20
THEN
OPEN
"0",t2,IICOPY":RESUME
120
2010 ON ERROR
GOTO
0
The error
trappinq
routine
in line
not
exist"
error
in
line
20.
statements
that
copy the file are
created
as if it were
a new
file.
2000 traps
a
"File
If
this
happens,
skipped,
and
"COpy'·
does
the
is
Creating
and accessing
random
files
requires
more
program
steps
than
sequential
files,
but there
are advantages
to
using
random
files.
One
advantage
is
that
random
files
require
less room
on the disk,
because
BASIC
stores
them
in
a packed
binary
format.
(A sequential
file
is stored
as
a
series
of ASCII
characters.)
The biggest
advantage
to random
files
is that
data
can
be
accessed
randomly,
i.e.,
anywhere
on the disk
-- it is not
necessary
to read
through
all
the
information,
as
with
sequential
files.
This
is possible
because
the information
is stored
and accessed
in distinct
units
called
records
and
each
record
is numbered.
The statements
and functions
that
are used with
random
files
are: