EasyManua.ls Logo

Sharp PC-1500 - Multi Pl• Statements Usi Ng the Colon

Sharp PC-1500
169 pages
Print Icon
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...
A
ll
and more about Sharp P
C-
1500 at http://
www
.PC-1500.info
Notice
hov1
each line
in
the program accomplishes a single complete and necessary step. Line
10 erases
any
previous values which mig
ht
be contained in
the
variables N 1, N2,
and
N3 (this
is
a
precaution in case
the
user fails
to
enter all
three
numbers). Line
20
collects
the
data
from the
user. Line
30
averages
the
numbers. Line
40
com
putes t
he
three differences. Line
50
sums
the
differences
and
li
ne
60
prints
the
result.
It is no accident
that
the instructions on each line correspond to the English language descrip.
ti
on
of
the
program. Instead, this
is
one
of
the
principles
of
good programming which you should
try
to
follow.
Unlike
the
use
of
abbreviations, the use
of
the
colon does affect
the
amou
nt
of
memory used
to store
the
program. This
is
the chief justifica
tion
for using
the
colon
to
place several statements
on
one line. Each line number
reserves
several
program "steps'' (a unit
of
storage) and therefore
the
fewer the line numbers
in
a program,
the
smaller memory size
of
lhe progra
m.
The
final
statement
about
the
use
of
the
colon
is
tha
t each programmer must balance each
program's readability
and
changeability against
the
st
or
age needs
of
his
app
lication.
J. Error Correction
in
the
PrO{lrarn
M.ode
Although abbreviations
and
colons help
us
to
easily enter programs, they
canno
t prevent
the
best of us from making m
is
tak
es. Even professional programmers fail to ca
tch
errors when
reviewing their
own
programs. What this
me
ans
is
that sooner or later
you
will encounter an error
while running
your
program (if
you
haven't already), Mo
st
of
these errors are easily corrected if
you simply accept them
as a
punle
to
be solved and carefully track
dow
n
the
problem. Several
features
of
the
PC-1500 will assist you in this.
Upon discoveru
ng
an incorrect statement SHARP will halt and indicate the problem with a
terse mes.sage such as:
I
ERROR
RUN
1
IN
20
Let's create a program with a deliberate error
fo
r purposes
of
illustration.
Enter:
Program Listing:
25
PAUSE "HUMPTY DUMPTY"
50
PRIMT "WAS
AN
EGGHEAD"
Keystrokes:
rn
mmrnrnm
m 1
••
,,,
,~
0Doo
oo
m
rnm
,.
..
c,
1
(]]OD
GD
m
!Il
[DI
••"'
I
~
le
n•
I
rn
oo m
rn
co
oo
rn
1 ... ,
,,1
~
oo
rn rn
1
..
•c
•1 m OD
1
..
•c.1 m
rn
rn
OD
mm
rn
''"'"'
~
l
t•
I
Now run
the
program. When
the
er
r
or
mesS<Jge
appears depress
the
[[]
(Up
Arrow) key.
As
long
as
you
hold
this ke
y,
the
display will show
the
li
ne
on
which SHARP became confused.
The flashing grid may provi
de
a
hint
as
to
the
n
ature
of
the
problem.
To
correct the· bad
sta
tement, press I
CL
I
to
quit
the
program
and
switch to
the
PROgram
mode. Press
the
Up Arrow key,
but
do
not
hold
it
, and
the
display
wil
I again show
the
erroneous
line:
42
Do
not sale this PDF
!!!

Table of Contents

Other manuals for Sharp PC-1500

Related product manuals