The program may now access the data
in
the buffer.
The following program accesses the direct-access file "LISTING"
(created with the previous program). When BASIC executes line
30, enter any
valid record number from "LISTING". This program
will print the contents of that record.
10
OPEN
"D",
1,
"LISTING",
32
20 FIELD 1
,20
AS
N$,4
AS
A$,8
AS
P$
30
INPUT
"2-DIGIT
CODE,
0
TO
END"
j
CODEX.
35 IF
CODE%
= 0
THEN
1000
40
GET
#1,
CODE%
50
PRINT
N$
60
PRINT
USING
"$$#.##"
j Cl.JS(A$)
70
PRINT
P$: PRINT
80
GO
TO
30
1000
CLOSE
1
After typing this program, SAVE it and
RUN
it.
When BASIC asks
you to enter a 2-digit code, enter 20 (the record we created
through the previous program). Your display should show:
2-DIGIT
CODE,
0
TO
END?
20
SMITH
$34.55
567-8000
If you entered a record number which is not a part of "LISTING",
your display would show:
$0.00
If you wanted
to
go back and update "LISTING", simply LOAD the
previous program (the one that created "LISTING") and
RUN
it.
2-57