Sharp PC-1500A Instruction Manual page 70

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

Advertisement

All
and
more
about Sharp
PC-1500
at
http://www.PC-1500.info
"character
array") you
may
also
specify
th
e
size
o
f
t
he
strings,
u
p
to a
m aximum of 80
charac ters
per stri
ng.
Creating
character
strings of
varying
sizes is
desc
dt:>ed
in
Sect
ion
8.1
.
To
define an
array
,
the
DIM
(sh6rt
for dimeMiM
)
statement
is
used.
Arraw
must
alwaw
be
"declared"
(defi
ned}
before
they
are
used. (Not
like
the
singl
e·value
variables
we have
been using
.}
The
form
for
the nvmeric
OIMension
statement is:
D
IM
nu
meric·variable·name
(size}
v1here:
numeric ·variable
·name
is a
variable
name
wh ich
conforms to
th
e normal
ru
les
for numeric
variable names
previou
sly
discussed.
~
is
the number of
storage locations
and
must be a n
umber i
n
th
e
range O
thro
ugh 255. Note
that
o.·1f)en
you
specify
a number
f
or
the
size
vou
get
o
ne
more
l
ocation
than
you
specified
.
Exitrnp
l~s
of
legal
numeric
DIMension
s tatemen ~s
are:
D
IM
X
(5)
OIM AA
(24
)
DIM
0
5
(01
The
first statement
creates an array X
\•Ji
th 6
storage locations
.
The second statement creates
an
array AA with
25
locations.
The
th
ird
statement
creates
an a rray
with
one
location
and
is
act
ually ra1her
silly since (for numbers at
least
t,
i1
is
the
same
as
declar
ing
a
singl
e
·value
numeric
variable.
It
is
important t
o
knovJ
that
an arrav
·vadable
X
and
a
11ariable
X
are separate and
distinct to
SHARP.
The
firs1
X
denotes
a
series
of
numeric
storage locations,
and
the second
a single
and
d ifferent
location
.
Now
th
at
you
knov1
hov1
to
cr
eate arrays,
you mi ght
be
wondering how
i
t
i
s
'\hat vie
refer
to
each
storage location. Since the
entire
group
has
only
one name, the way
in
which
we
refer
t
o
a
single
location
(called an
"ele1nent"~
is
to
follow
t
he
group
name
w ith a number
in parentheses.
This
number is ca lled a
"subscript".
Thus,
for example.
to
store the number
8
into
the
f ifth
•lcmcnt
of
our
array
X
(declared
previ
ously) we
would
write:
x
(4)
=
8
If
the use
of 4
is
puzzling,
remem ber
that
t
he
numbering
of
elements
begins at
zero
and
continues
th
rough
the
size
number
declared
in
the DIM statemen
t.
Th
e reaf
power
of arrays lies
in
the
ability to
use an
exp
ression
or
a
variable
name as
a
sub·
scrip
t.
For
example
,
to
create
a table
containing
the squares
of
t
he
numbers
0
to
9 we
could
\vrite
the following
statements:
10
DIM
SQ (9)
20
FOR
I=
0
TO
9
30 SQ (l)
=
l*I
40
NEXT I
Do not sale this PDF
!!!
68

Hide quick links:

Advertisement

Table of Contents
loading

Table of Contents