Download Print this page

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

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

Advertisement

DISK BASIC
PRINT*!
t
a$;
h
*"
;b$
would
produce:
JOHN
Q.
DOE* 100-01-001
which
could be
input#
back
into
two
variables.
This
method
is
adequate
if
the string data contains
no
delimiters
commas
or
(ENTER)
characters.
But
if
the data
does
contain delimiters or leading blanks
that
you
don't
want
to
ignore,
then
you must
supply
explicit
quotes
to
be
written
along with
the data.
For example, suppose A*
=
H
DOE* JOHN
Q
t
!I
andB$
=
"100
-01-001"
If
you
use
PRINT*!
*A*i"
>"
?B$
the disk
image
will be:
DOE* JOHN
0*
*100-01-00i
(ENTER)
When
you
try to
input
this
with
a
statement
like
INPUT#2*A$*B$
a$
will
get the
value
doe, and
b$
will
get
john
q.
because
of
the
comma
after
doe
in
the
disk
image.
To
write
this
data so
that
it
can be
input
correctly,
you must
use
the
chr$
function
to insert explicit
double
quotes
into
the disk
image. Since
34
is
the
decimal
ascii
code
for
double
quotes,
use
chr$(34)
as
follows:
PRINT#1 *CHR$(34> 5A$SCHR*<34)
iB$
this
produces
the disk
image
"DOE* JOHN
Q,
"100-01-001
CENTER]
which
can be read with
a simple
INPUT*2*A$B$
Note:
You
can
also
use
the
chr$
function
to insert
other delimiters
and
control
codes
into the
file,
for
example:
chr$(10)
©
Line
Feed
chr$(13)
carriage return
(
(ENTER)
character)
chr$(H)
or chr$(I2)
line-printer
top-of-form
USING
Option
This option
makes
it
easy
to
write
files
in
a carefully controlled format.
For example,
suppose:
A$=
n
LUDWIG
if
133

Advertisement

loading