Sharp PC-1500A Instruction Manual page 43

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

Advertisement

All
and
more
about
Sharp PC-1500
at
http://www.PC-1500.info
1.2.
Multiple
Statements
and the
Colon
As
mentioned
in the section on line numbers,
several statenlents may share the same
li ne.
SHARP will execute the
statements in
sequence
from left
to
right.
In
order
for SHARP
to
be
able
to distinguish the end
of
one
statement
from
the
b~ginnin
g
of the next,
some "signalling"
character must
be
used.
This c
haracter
is the
colon
(:
).
By
analogy,
the
function of the c<>lon
is
similar to
the
function
of
the
periods
which
s-eparate
the sentences
on
this page;
it
tells o ne
\vhen
to
stop reading.
The
use
of the
colon
has already been illustrated in
several o
f
the
last few
sample
programs.
Its
general form
is
as rollows:
line·number
statement 1 : statement2
:
statement3 (etc)
The question of when
to
use the colon
is
a
matter
of programming
style.
Indiscriminate use
of
the colon to write
very
comp.
a ct
programs
produces
programs
which
are
very difficult
to
read,
correct, or
expand.
Since the
prime advantages
of
the
PC-1500A
are that it
is
personal
and
inter·
active,
it
is
highly
desirable that you are
able
to
modify
and
extend
programs to
su it you
r own
needs.
\Ve therefore
recommend that
you exercise
restraint
in
your
use
of
the
colon.
If you
do use the colon, it
is
very
advantageous to group
only
those
statements
which
are
con-
ceptually related.
That is, place only those few statements
which
accomplish
a
single
task,
out of
the many
possible tasks
that comprise the program,
on
one
line.
For
example, consider
the following program
statements
which
read
in
three
numbers. find
their
average, compute
the difference
of each number
fro
m
the
average,
and
pri nt
the sum of these
differences:
Program Listong:
10
N1
=
0
:
N2
=
0
N3
=
0
20
INPUT
' 'ENTE
R
3
NUM BERS", Nl,
N2,
N3
30
A
=
(N 1
+
N2
•·
N3)
/
3
40
Dl
=
N1
-A:
D2
=
N2-A
D3=N3
-
A
50 SD
= D 1 +
D2
+
D3
60
PR
INT
.. SUM
OF DIFFERENCES
=
";
SD
Keystrokes:
CDOOf"llJ
rn
1=1001
...
.,,,
oODm
1=1
rn1
••"T'
ooorn
I
"
I
Cl)
l••n•I
rn
rn
m
OD moo
rn
1
..
1
,,
1
c:J
co
OD
rn
IIl
m 1
..
•<•I
rn
,
...
e.1
oo
o:o
oo mm mm 1
S
H
IFT1
c::i
1
..
1,,T
1
m
QIJ
m
ISH1
H!
m crorn
!SHIFTI
CLJ(J[]
rn
!••rt•!
rnoorn1 =1
m
oornrn
aorn
moornmmrn
1
'"''"'
rn
rnmrn1
=10DmGrn1
..
1 "
1
o
rn
rni
=10Drnsrn
'"""'
'
o
rnrn1 =1
ao
rn
s
m
''""''
mmm
rnr=1rnmmrnmrn
rnrn
''"''"'
lil
00
mm
co
00
co
I SHIFT
I
c:J
C§J
CTO
00
!
SP•c•I
rn m
ts••<"'
rn
comm
m
rn
m rn
m
m
m
I=
I
ISP«•!
1
SHIFT
1
CJ
1
sH"'
1
o
m
m
«"'''
1
Do not
sale
this PDF
!!!
41

Hide quick links:

Advertisement

Table of Contents
loading

Table of Contents