A
ll
and more about Sharp PC
-1
500
at http://www.PC-1500.info
1.2. Multiple Statements
and
the
Colon
As mentio
ned
in
the section
on
line numbe
rs
, sevetal statements may sh.are the same line.
SHARP will
cx<.>cutc
the statements in sequence from l
ef
t
to
right. In
ord
er for SHARP
to
be
able to distinguish the end
of
one
st
aterne
nt
fr
om
the
beginning
of
the next, some
"s
ignalling"
character
rnust
be u
sed.
This
cha
racter
is
the
colon
{:
). By analogy, the funietion
of
the colon
is sim
ila
r to the function
of
the p
eri
od
s
wh
ich separate the se
nt
ences
on
this page; it tells one when
to
stop
reading.
The use
of
th
e colon has already been illus
tr
ated
in several
of
the
la
st
few sample programs.
It
s
general form
is
as
follows:
line-n
umber
statement 1 :
statement2
:
staternent3
(e
tc)
The
qu
estion of when to use
the
colon is a
matter
of
programming style. Indiscriminate
use
of
the col
on
to w<ite very compact programs
prod
uces programs which are
ve
ry diffi
cult
to
read,
correct,
or
exp
and
. Since
the
prime advantages of the PC-1500 are that
it
is
pe
rsonal and inter·
ac
tive, it
is
highly desirable
that
you are able to m
od
if
y and extend programs
to
iuit
yo
ur
ow
n
needs.
We
therefore recommend th
at
you exercise restraint
in
yo
ur
use
of
the
colon.
If you
do
use
the c
olon,
it
is very advantageous
to
gro
up
only
those statements
wh
ich a
re
c
on·
ceptually
rel
ated
. That is, place
on
ly those few s
tat
ements which accompli
sh
a single task,
out
of
the
1nany
possible tasks that comprise the program,
on
one line.
For
example
..
consider the following progrilm s
t.J
tcme
nt
s which
read
in
three numbers, find
their average,
compute
the
di
fference
of
each number from the
av
erage,
and
print
the sum of
the
se
differences:
Pro
gr
am Listi
ng:
10
N 1 = 0 :
N2
= 0 N3 = 0
20
INPUT "ENTER 3
NUMB
ERS
",
N1, N2, N3
30
A = (N 1 i · N2
,.
N3) I 3
40
0 1 =
N1
- A : 0 2 =
N2
· - A 0 3 = N3 - A
50
SD = D 1 +
02
+
03
60
PRINT "SUM
OF
DIFFER
EN
CES =
";SD
Keystrokes:
OJ[IJ[][)CIJ
( =
l[@JI
S
0<0Fr
l
CJ[][)[D
I =
IOO
l
>H
IF
Tl
(TI[][]aJ
1 =
1rn1
'"
""1
mm rn
oo
moo
rn
1 •• ,
,.
1
c::i
rn
ou m
moo
1
...
•«
I
rn
(
SPA
CCJ
[f{J[]J
C!ilJ(!JfEJ(I)
(Ij
l
sH
IF
TI
c:::J
)
SH
on
lGJ
[][)
m ,
...
,,,
1 cu
CE)
aJ
I •••
FT)
GJ
[][)
rn
l
<HTOl
l
rnmrn
1=
im
oo
mrn
oomrnoorn
rnrnrn
1••m1
mrnoo
rnwoorn0m1
~
·
"1
orn
m1
=
1[][]00Grn
1
.....
TI moorn1 = I
OOC!J
G
rn
l
••T<
•I
mrnrnoo1
=1
oornrnoomrnrnrn
1
••
,
,,.
1
m oo
mm
rn
m co 1 ... .,,1 c::i m
o:o
oo
l•••
«I
rn m 1
...
c.
1 rn
com
moo
mm
DD
fJD m m
I = I (
SPAC<
I
I
SH•
FT
I
CJ
I S
HIF
TI
c:J
m
OD
l
••n•
I
41
Do
not sale this PDF
!!!