Radio Shack TRS-80 User Manual page 22

Micro computer system
Hide thumbs Also See for TRS-80:
Table of Contents

Advertisement

Now
suppose
we
want
to
include
both
the value of
something
and some
exact
words on
th
same
line.
Pay
attention,
as
you
will
be doing
more
and
more
program
design
yourself,
and
PRINT
statements
give
beginners
more
trouble
than
any
other
single
part of
computer
programming.
Type
in
the following:
50
PRINT
"THE
DISTANCE
(IN
MILES)
IS",D
EZH33
Then
run
anna
The
display
should
appear:
THE
DISTANCE
(IN
MILES)
IS
3000
(REMEMBER:
Typing
hi
a statement with a
Hue
rramber
that already
Is
ih
use
erases
the
original
'
statement
uritirety -~
and
that's
what
we
want
to
.;
do
here,)
How
about
that!
The
message
enclosed
in
quotes
is
printed exactly
as
we
specified,
and
the
letter
gave
us
the value of
D.
The
comma
told
the
Computer
that
we
wanted
it
to print
two
separate items
on
the
same
line.
We
can
tell
it
to print
up
to
four items
on
the
same
line,
simply
by
inserting
commas
between them.
With
this in
mind,
see
if
you
can change
line
5(3
so the
computer
finishes
the
program
with
the following
message:
THE
DISTANCE
IS
3000
impm
MILES,
Break
up
the
quoted
message
into
two
parts,
and put
the
variable
in
between
them on
the
PRINT
line.
50
PRINT
"THE DISTANCE
IS"
,
D
,
"MILES."
Now
what about
all
that extra space
on
the printout line?
The
reason
for
it is
that the
com-
puter
divides
up
the screen width
into
four
zones
of
15
characters each.
When
a
PRINT
statement
contains
two
or
more
items separated
by commas,
the
computer
automatically
prints
the items
in
different print zones.
Automatic
zoning
is
a very
convenient
method
of
outputting tabular information,
and
we'll
explore the subject further
later
on.
It's
possible to
eliminate
all
that
extra space
in
the
output from our
Distance, Rate,
Time
program.
Retype
the
last
version
of
line
50, substituting
semi-colons
(;)
for
commas
throughout
the
line.
run
Bzngj
The
display
should
appear:
20
jJGarefui
don^fc
renUjqe the
perfftcf
'With
««emi*
'
eoloiu),
..:'.....
„...;:.,.„.
..,...;
.'....:':.
''•':
t-'--

Hide quick links:

Advertisement

Table of Contents
loading

Table of Contents