EasyManua.ls Logo

Radio Shack TRS-80 - Page 150

Radio Shack TRS-80
236 pages
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Loading...
Now
For
the
Good
News
Despite
the
frustration
these so-called
"logical"
symbols
inflict,
using them
is very
simple.
Type:
10 Y=l :N=0
20
IN,
"IS
GATE 'A' OPEN"
;A
30
IN. "ISGATE 'B'
OPEN"
;B
40 IN.
"ISGATE
*C'
OPEN"
;C
50
PRINT
60
IF <A=1)
*
(B=l)
*
(C=l)
THEN 100
70
P.
"OLD
BESSIE IS SECURE
IN
PASTURE # 1 .
*'
80
END
100 P. "ALL
GATES ARE OPEN. OLD
BESSIE IS FREE TO
ROAM."
Be sure to
use the Shift-7 key to
get
the single
quote
mark.
.
„...
Remember.
. it
we're
using
*
here
as
the logical
. . . and
RUN.
Answer (Y/N) the
questions
differently during RUNs to see
how
the logical
AND
works
in line
60.
Where
is
the LOGIC in all this?
You
should
by now
understand
every line in
the
program except
perhaps line
60.
Line
10
initializes the Y and N
values at 1 and
respectively.
Lines
20,
30
and
40 input the gate
positions as open
(which we defined as
equal
to
"1"),
or closed
(defined
as
"0").
We
could
have defined
them
the other way around in
line
10
and
rewritten
line
60
to
match,
if we'd wanted
to.
Line
60
is the key. It
reads, literally,
"If
gate A is open, AND
gate B is open, AND
gate
C is open,
then go to
line
100.
If any one
gate
is closed,
report
that fact by defaulting
to line
70."
Imagine how
this simple logic
could
be used to
create
a
super-simple
"computer"
consist-
ing
of
only an electric
switch on each gate
add a battery and
put a light
bulb
in
the
farmer's
house.
The bulb
could
indicate whether
the gates are
all
open.
Such a "gate-
checking"
computer
would have only three
memory
cells
the switches.
148
Hmm. It
would
do
the job
a
lot cheaper
tba»Vfc-
fRS*8G
'..
.
.but
would
be
awfully hard to play
Blackjack with.
..

Other manuals for Radio Shack TRS-80

Related product manuals