A
ll
and more about Sharp PC-1500
at
http://www.PC-1500.info
The
cost
o f a widget is stored
in
vari
a
ble
X. Assuming a
6.5
% sales
t
~x.
wh~t
is the
purchase price of the widget? :
x = x *
1.
065
Of
course,.
we
could have .written this example as P = X *
1.065
in
order to leave X
unchanged. If we had stored
the tax
rate in a variable
T,
we
could
have
sa
id X = X * T
or
P = X
*T.
Unti
l
now,
\•Je
have been using single le
tter
s
as
variable names.
Th
is p
ro
vided
us
wi
th
26
va
riables (A
th
ro
ugh Z).
In
actuality, SHARP allows the use
of
over
950
variable names for single
numbe
rs
.
An
ad
~
ditiona
l
group
of
over
950
1Jariables
may
be
used
to store up
to
16
ch
aracters each.
Finally (as if
that
\vercn't enough), using
more
advanced techniques, users
may
create
var-iables
v1hich
ho
ld
as
many numbers or characters as desired, limited
only
by
the a
mo
unt
of
memo
ry
available
in
the
computer.
The
naming-scheme for variables
is
si
mple
and
easy
to
learn. Names
of
numeric
va
riables
{ones used
to
ho
'ld numbers) may be chosen
usin!1
the
following rules:
-
The
name may
be
a letter; A through Z.
-
The
name may be a letter, followed
by
a single digit
(O
through
9)
or
by
another letter.
Thus.
the
following are
val
id names for numeric variables:
S,
0
1,
TX,
MM
, Z9,
RO,
E.
NOTE: Due
to
conflicts with abbreviations which have
other
me
anings in
th
e BASIC language,
SHARP does
not
allow the use
of
these
va
riable names: LF, IF, LN, Pl, TO.
Names
of
character
variables {those used
to
hold characters) follow
the
same
rules as above
except
that
the
name
ends with
a$
(dollar
si
gn}.
The$
alerts SHARP
to
th
e fact
that
the
variable
ho
lds character
in
formation.
The
following are examples
of
va
li
d character variable names:
T$, P2$,
T7S
, AAS, YRS, XS, ZHS, B5S.
NOTE: Due
to
conflicts
with
wo
rds which are
part
of
the
BASIC language, SHARP does
not
allow
the use
of
these variable names: LFS, IFS, LNS, PIS, TD
S.
It
is
importarnt
to
understand
that
a
v.:i
riable A and a variable
AS
are
two
different variables, the
first
one
can
only
hold a
number
and
the
second
one
can
only
hold character
s.
As we shall see
later, SHARP's BASIC includes instructions
to
convert characters
to
numbers
and numbers
to
characters.
To
store characters in character variabl
es
i.ve
use
a v.:iriation
of
our friend the Assignment
Statement:
ch;:iracter.va
ri
ab
le
·na
me
= "characters''
As
an example
type
the following:
OS
=
"DAVY
JONES"
Now recall
the
contents
of
OS
by
tyring
(][)
rn
I
ENTER
I
DAVY JONES
23
Do
not sale this PDF
!!!