Advanced Programming; Arrays And Subscripted Variables; Dim - 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
Ex•mple
3:
I
NT 31.62
+
21.18
I
<
•1<•1
§
.
18
~
The computer takes
that IN
T
of
t
he
first
number 31.62
(result:
31)
and
adds
that
to
21 .18
to
get
52.18. This
is
sli!Jhtly
d
iffer
ent
from
the
first computation,
eh?
SGN
fo(
any
number
X
the
SGN
function
returns
a
value indica1ing
if
the
number is negative.
zero,
or
positive.
The
values arc
the
fioll0\•1i
n9:
if
x
>
o
0
if
x
=
0
-
1
if
x
<
Q
Examples:
5
-
10
!EHT£
1t!
-s
J
SGN
(5
-
10)
HT
E1tl
-1]
t
2 -
4
)
£HT£.1t
i
~
SGN
( 12
-4)
IEHT
EAI
1
I
15
-
15
I
(NTl!A
l
01
SGN (15
-
15)
i
f
NTfRI
01
V. ADVANCED PROGRAMMING
A. ARRAYS and
the
DIM
Statement
Most
of
ou
r sample programs to d
ate
have used a
small
number
o
f
variables.
As you
begin
to
utiliie the full
processing
POtential
of the
PC· I
500A you will
discover
that
variables
which hold
a
single
nurnber
can have
drawbacks.
Perhaps, for
exampl
c, you
arc
considering
a p rogram
which
reads
in
fifty
numbers
and
sorts
t
hem
.
You may <
1u
ickly
conclude
that,
although
the
PC·
I 500A
has more than enou:gh POtential variables,
there
must be
an
easier
way.
There
is,
:and
it
is
called
an "array
variable"
.
An
array is
simply a group of consecutive storage
areas
.
or
"locations". w ith a single
name.
Each stora9e
area
car> hold
a
si°ngle
n
umber
or
each
storage
area
can
hold a
character
string.
All o
f
1he
storage areas
with in a
gi ven
array
must
hold
the
same
type
of
data.
The number
of
locatio
ns
with
in
a single
array
may be as
m
any as 256
and
is
determined by
your
specification
.
Thus,
i
f
you
define a
numeric array
with
50
locations.
this
alloi,,vs
you to
store
up to
50 numbers in
associatm
on
with
a
single
name.
If
you
define
an
array of
strings
(cal
led
a
Do not sale this PDF
!!!
67

Hide quick links:

Advertisement

Table of Contents
loading

Table of Contents