Download Print this page

Radio Shack TRS-80 Owner's Manual page 171

Mini-disk operation disk operating system disk basic programming language
Hide thumbs Also See for TRS-80:

Advertisement

\m\
DISK BASIC
sSBBESj*
Random
Access:
A
General
Procedure
The
previous
example shows
the
necessary sequences
to
read
and
write
using
random
access.
But
it
does
not
demonstrate
the
primary advantages of
this
form
of access
in particular,
it
doesn't
show
how
to
update
existing
files
by going
directly to the
desired record.
The
program
below,
glossacc/bas,
develops
the
glossary
example
to
show
some
of
the
techniques of
random
access
for
file
maintenance.
But
before
looking
at
the
program,
study
this
general
procedure
for creating
and
maintaining
files
via
random
access.
Step
See
GLOSSACC/BAS,
Line
Number
1.
Open
the
file
110
2.
Field
the
buffer
120
3.
Get
the record
to
be updated
140
4.
Display current contents
of
the record (use
145-170
CVD,
CVl,
CVS
before displaying
numeric
data)
5.
LSET
and
RSET
new
values
into
the
fields
210-230
(use
MKD$,
MKI$,
MKS$
with
numeric data
before
setting
it
into
the
buffer)
6.
PUT
the
updated
record
240
7.
To update another
record,
continue
at
step
3.
250-260
Otherwise,
go
to
step
8.
8.
Close
the
file
270
10
REM .,,,..
GLOSSACC/BAS
.
,.
100 CLS
:
CLEAR 300
110
OPEN
"R"»
1.
"GL0SSARY/BAS"
120
FIELD
IB
AS
WD*
,
238
AS
MEANING**
2
AS
NX*
130 INPUT
"WHAT RECORD DO YOU WANT
TO ACCESS'
1
!
R%
140 GET
1
,
RI
145
HXl
=
GUI (NX*)
'SAVE LINK TO NEXT
ALPHABETICAL ENTRY
150
PRINT "WORD
;
"WD$
160
PRINT "DEF'N
:
"
;
PRINT MEANING*
170
PRINT "NEXT
ALPHABETICAL
ENTRY; RECORD
»:"
NX!
:
PRINT
180 W$
=
""
:
INPUT "TYPE NEW WORD <ENTER>
OR
<ENTER>
IF
OK"
5
W*
190 D*
=
""
;
PRINT "TYPE NEW DEF'N
<
ENTER
>
OR
<ENTER>
IF
OK?"
;
LINE INPUT
D$
200 INPUT "TYPE NEW
SEQUENCE NUMBER
OR
<ENTER>
IF
OK"? NXI
210
IF
W$ <>
""
THEN LSET WD*
=
W*
220
IF
D* <>
""
THEN LSET MEANING*
=
D$
153

Advertisement

loading

This manual is also suitable for:

Model iii