Download Print this page

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

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

Advertisement

DISK BASIC
First
we
decide
what
the data
image
is
going
to
be. Let's
say
we
want
it
to
look
like
this:
english
unit
) metric
unit,
factor
(ENTER)
For example,
the stored
data
would
start
out:
IN->CMf 2*54001
CENTER)
The
following
program
will create
such
a data
file.
Note:
X'OD' represents
a carriage
return.
10
OPEN
"0"
tl
t"METRIC/TXT"
20
FOR
11=1 TO
7
30
READ UNIT*, FACTR
40
PRINTttl
f
UNIT$;
"
#"
3
FACTR
50
NEXT
G0
CLOSE
70
DATA
IN->CMf
2*54001
t
MI->KM»
1*60935*
ACRE->SQ
*
KM
t
404G.8S
E-G
80
DATA
CU.IN->LTR>
l*G3871GE-2t
GAL->LTR
,
3*785
30
DATA
LIQ*QT->LTR*
0*84G3»
L6->KG>
0*45359
Line
10 creates a disk
file
named
metric/txt, and
assigns buffer
1
for sequential
output
to that
file.
The
extension /txt
is
used because
sequential
output
always
stores the
data
as
Ascii-coded
text.
Note:
If
metric/txt
already
exists, line
10
will
cause
all
its
data
to
be
lost.
Here's
why:
Whenever
a
file
is
opened
for sequential output, the end-of-file
(eof)
is
set
to
the
beginning of
the
file.
In
effect,
trsdos
"forgets"
that
anything has ever
been
written
beyond
this
point.
To
avoid
this,
you
could use e
instead
of
o
in line 10.
Line
40
prints
the current contents
of units
and
factr
to
the
file.
Since
the
spring items
do
not contain
delimiters,
it
is
not necessary
to print explicit
quotes
around them.
The
explicit
comma
is
sufficient.
Line
60
closes the
file.
The eof
is
at
the
end
of
the
last
data item,
i.e.,
0.45359,
so
that
later,
during
input,
basic
will
know when
it
has read
all
the data.
Sequential Input:
An
Example
The
following
program
reads
the data
from metric/txt
into
two
"parallel"
arrays,
then asks
you
to
enter a
conversion problem.
5
CLEAR 500
10
DIM
UNIT*(9)t
FACTRO)
'allows for
up
to
10
data pairs
20
0PEN
H
r'
tl
"METRIC/TXT"
25
n,
=
30
IF
EOF(l) THEN
70
40
INPUT*!
»
UNIT$(II) tFACTR(IX)
147

Advertisement

loading