Download Print this page

Radio Shack TRS-80 model III Owner's Manual page 154

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

Advertisement

DISK BASIC
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,
gloss
acc/b
as,
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
2.
Field
the
buffer
3.
Get
the record
to
be updated
4.
Display current contents
of
the record (use
CVD,
CVI,
CVS
before
displaying
numeric
data)
5.
LSET
and
RSET
new
values
into
the
fields
(use
MKD$,
MKI$,
MKS$
with
numeric data
before
setting
it
into
the
buffer)
6.
PUT
the
updated
record
7.
To update another
record,
continue
at
step
3.
Otherwise,
go
to
step
8.
8.
Close
the
file
110
120
140
145-170
210-230
240
250-260
270
10
REM
100
CLS
:
110
OPEN
"
120
FIELD
130
INPUT
U0
GET
1
*
145
HX'l
=
150
PRINT
1G0
PRINT
170
PRINT
180
m
=
"
W$
190 0$
=
»
OK?"
:
200 INPUT
210
IF
m
220
IF
D$
...
GLOSSACC/BAS
...
CLEAR 300
R"
.
1
>
"GL0SSARY/BAS"
IS
AS WD*» 238 AS
MEANING*.
2
AS NX*
"WHAT RECORD
DO YOU
WANT
TO
ACCESS"!
RX
CVHNX*)
'SAVE LINK
TO
NEXT ALPHABETICAL ENTRY
"WORD
:
"WD*
"DEF'N
:
"
:
PRINT MEANING*
"NEXT
ALPHABETICAL
ENTRY: RECORD
*:"
NXX
:
PRINT
"
:
INPUT "TYPE NEW WORD <ENTER>
OR
<ENTER>
IF
OK
"
"
:
PRINT "TYPE NEW DEF'N
<
ENTER)
OR
<
ENTER)
IF
LINE INPUT
D$
"TYPE NEW SEQUENCE NUMBER
OR
<ENTER>
IF
OK"
5
NX*
<>
""
THEN LSET WD*
=
W*
<>
""
THEN LSET MEANING*
=
D*
./-"
153

Advertisement

loading