Download Print this page

Radio Shack TRS-80 Owner's Manual page 165

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

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->CM» 2.54001
(INTER)
The
following
program
will
create
such a
data
file.
Note:
X'OD' represents a carriage
return.
10
OPEN
"0"
>l »"
METRIC/TXT"
20 FOR I%=1 TO
7
30
READ UNIT** FACTR
40
PRINT*1
t
UNIT*I
"
»"»
FACTR
50
NEXT
G0
CLOSE
70
DATA
IN->CMj
2,54001s
MI->KM>
1,60935*
ACRE->SQ.KM
»
4046,86 E-E
80
DATA
CU.IN->LTR>
1.G3871GE-2.
GAL->LTR»
3,785
90
DATA
LIQ,QT->LTR»
0,9463*
LB->KGt
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
Ascn-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$C9)* FACTRC9)
'allows for
up
to
10
data pairs
20
0PEN"I"
>1
»"METRIC/TXT"
25 IX=0
30
IF
E0F(1) THEN 70
40
INPUT*1*
UNIT$UI>
»FACTRIIX)
wmmmm^mm>km«fmi
147

Advertisement

loading

This manual is also suitable for:

Model iii