Error Correction In The Program Mode - Sharp PC-1500A Instruction Manual

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

Advertisement

All
and
more
about Sharp PC-1500
at
http://www.PC-1500.info
Notice
how
each
line
in
the
program
accomplishes a single
complete
and necessary step. Line
10 erases any
previous
values which might
be
contained
in
the
variables
NI, N2,
and
NJ {this
is
a
precaution in
case t he user fails to
enter
all three
numbers).
Line
20
collects the data
lrom
the
user. Line
30
averages the
numbers.
Line 40 computes the three
differences. Li
ne
50
sums the
dillerences and line
60
prints the
result.
It
is no accident
that
the
instructions
on
each
line correspond to the English language descrip-
tion
of the program. Instead
,
this
is
one of the
principles
of good programming which you should
try
to follow.
Unlike
the use
o·f
abbreviations. the use o
f
the
colon docs
affect
the amount o
f
memory
used
to store the program. This
is the chief
justification fo
r
using
the
colon to
place
several statements
on
one
line.
Each
'
l
ine
number reserves
several
program "steps"
(a
unit of
storage)
and therefore
the fewer the line
numbers
in
a
program, the
smaller
memory size of the
program.
The
f
inal
statement about the
use of
the
colon
is
that
each
programmer
must balance each
program's readab ility and
changeability
against
the
storage needs
of
his
application.
J. Error Correction in the Program Mode
Although abbreviations
and colons
help us to
easily
enter
programs, they cannot
prevent the
best
of us
from making
mistakes.
Even
profcss:ional
programmers
fail to
catch errors
when
reviewing their
own
programs.
What
this means
is
that
sooner
or
later
you will encounter an error
while
running
your
program
{if
you haven't
already).
Most
of these errors
are
easily corrected if
you simply
accept t
hem
as
a puzzle to
be
solved a
nd
carefully
track
down the
problem.
Several
features
of
the
PC·
1 SOOA will
assist
you
in
this.
Upon
d
iscoverin.g an
incorrect
statement
SHARP
will
halt
and
indicate
the problem with a
terse
message
such
as:
[i
~
RQR~l~_
l
_
N
~
2_0
~-R
-
uN
~
~~
Let's create
a
program with a del
iberate error for
purposes of illustration.
Enter
:
Program
Listing:
25
PAUSE
"HUMPTY
OUMPTY"
50
PR IMT
"WAS
AN
EGGHEAD"
Keystrokes:
r n m m
rn
rnOOCTJl
sHon
l
l:::::J00W
00
ffiffiffi
lsPAC£1
rn
w
oo
mm
m
1SH•
"
1
c:::J
1
• ., ••
1
oo rn
mm co
oo
m
1
"""'1
c::i
oo
rn oo ,
...
'"'1
mm
ISP•c•I
CT] [li] CT[)
QO(D[D
rnJ
IStt1rr
l
l:::::J
l••TE•
I
Now
run the
program.
When
the
error message appears depress
the
OJ
{Up Arrow}
key.
As long as you hold
this
key,
the display
will show
the line
on which SHARP
became
confused.
The
flash ing
grid
may provide a hint as to
the
nature of
the
problem.
To
correct the bad
statement, press
!ID
to quit
the
program and
switch
to the PROgram
mode.
Press the Up
Arrow
key,
but
do
not
hold
it,
and
the
display
will
again
show
the
erroneous
line:
42
Do not sale this PDF
!!!

Hide quick links:

Advertisement

Table of Contents
loading

Table of Contents