A
ll
and more about Sharp P
C-
1500 at http://www.PC-1500.info
Now
the
Gener.
al
calculates t
he
actual purchase price
at
t
he
PX:
G -
(G
* .
10)
+ 8 '' "" "'
0£C RUH
•
and the purcha
se
price
at
Discount Bernie's:
G -
(G
*
.05
) l
•NT•
•I
Di
Ci
RUH
.-
••
- .
....,.
-i-
...
t:"
. l
•:i
..::.
•
.:1
....
t'i
·-'
Clea
rl
y,
Discount
Be
rn
ie's has the better bargain. (Clever readers
may
have
notic
ed that
the
General
could
have worked this problem using SHARP's unique rec;i
ll
fea
ture
(see Chapter
2), though
not
qu
ite as easily).
There are
several lessons
to
be learned from the preceeding
exa
mple .
..
Observe
that
the
General's first calculation had the following form:
variable.name = expression
An
instruction \Vith
this
form is kn
own
as an
Assignment
Statement.
It
is
important
not
to
confuse
an Assignment sta
tement
with an inequal ity. Unlike Assignm
ent
statements, inequalities
are
not
used
sepa
r
.ate
ly, but
form
parts of other
progra
mm
ing
ins
truct
ions
.
The
Assignment
statement
instructs SHARP
to
store
the
result,
obta
ined
by
calculating the
expression, in
the
memo
ry
location associated
\•Jith
the given variable name. Thereafter, using
the name
of
the
variable
(G
in
our
example}
is
just
like using the result itself. Notice also
that
a
1Jariable
may
be
used
as
many
ti
mes
as needed in th e
same
calculation.
Variables
c;Jn
be
used
for other n
eat
tric
ks
,
too
.
Th
e
val
ue
of
one
va
riable can he
assigned
to
another, as in
the
·statement:
H = G
which
\Viii
copy
our
previo
us
result
into
H. G h
as
not
b
ee
n altered; the same
res.1Jlt
is
no111
stored
in
r.vo different variables.
Voriables
wh
ict\
hol
d nu1nbers can be incremented
or
decremented
in
one
sta.tement as
in
this
example:
G = G + 5
This instruction
will
cause SHARP
to
recall
the
value
of
G, add 5
to
that
value, and
st
ore
the
new value back
into
G. This capability
is
useful
for
all kinds
of
calculations:
22
Do
not sale this PDF
!!!