Sharp PC-1500A Instruction Manual page 52

Hide thumbs Also See for PC-1500A:
Table of Contents

Advertisement

A
ll
and
more
about Sharp
PC-1500
at
http://www.PC-
1500.info
Unfortunately, this program will
just
keep
"
c
hugging"
along
forever.
(You
may stop
the
program
by using the BR EAK
key
I.
We should provide a way for such programs
to end. We
can
do this by using a "counter" along 'wVith an
IF statement.
A
counter
is
a
variable
in which we
keep a
record
of how many
times
we
have
done
someth
ing
(i.e.
we count
witlh
it). With this
technique
the IF
statement will test
whether
we
have
performed our
PRINT statements
a
predeter.
mined number of times.
Of course,
it
is
entirely
UlP to us to determine
the
number
of
repetitions.
Let's
pick 10
times
for
each
PRINT statement
(after
10
times I get
bored).
Using our counter and
IF statement
we
can
write:
Program
Listing:
10
WAIT
30
15
C
=
1
20 PR
INT
"CHUG
CHUG CHUG CHUG"
30 PRINT "
CHUG
CHUG
CHUG
CHUG"
40
C
=
C+
1
50
IF
C<
=
10
THEN 20
60
END
Keystrokes:
ITJ
m
00
rn
CD
CD CD
(]J
l•••••I
CD!IlO::JI
=
ICD
I•••••!
rn
mm
OlJ
CD
ao
c:o
1SH"'1
c::i
moo
OD
rn
1
•••c•1
mCBJODGDISP•c•I
C£:J0DOD001•••c•I o;JCEJ
OD
[I)
ls•OF•I
c:J
lE••E
•I
m
m mrn
CD
ao
[!]
fS><oFT
I
CJ
ls ..
cEI
lsP>CEI
l•••c•I
ISP•C•I
lS••CEI
m
OD
0:0
rn
lsPACEI
m
C[J
OD(][)
l•••c•J
moo
m m
1
...
cc1
mm on oo
1'""'1
C'.J
moo
mt
=
1
m
rn
rn
l•••••I
m
oomm
m1
••"•1m1
=
1rornrn
ao
mao
m[101 ••r<•I
mrnmOTJrn1
.....
,
Follow
the
operation of
the
counter
as
each
lo
op
is executed
.
Notice that in
line 15 we
must
assign the
counter
an initial
value.
On line
40 we
increment this value to reflect
one more
execution of statements 20 and 30.
There are many
other ways to use
counters an.d
loops
within
programs.
Unfor·tunately,
we do
not
have the
space to describe
them here. We
suggest
that
you pursue your
education \.Vith
one
of
the books
listed
in
Appendix
F.
The GOTO
instruction is
a command
as well
as
a statement.
As a
command
its use is
naturally
d ifferent
from its use as a program
statement. Issued
as
a
command,
in
the
RUN
mode,
GOTO
begins
program execution
in a
manner
similar to
the RUN
command.
T
he
difference
lies
in
certain
internal
preparations
w·hich are
made
before instructions of
the
program are
performed.
(For a
50
Do not sale this PDF
!!!

Hide quick links:

Advertisement

Table of Contents
loading

Table of Contents