Sharp PC-1500A Instruction Manual page 71

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

Advertisement

All
and
more
about Sharp PC-1500 at http:/lwww.PC-1500.info
In
this
example.
the
variable
I
is used to select
which
s
torage
location
wi
ll hold
the
resul
t
and
it
is
also
being used
to
compute
the result.
To declare a
c.
h
aracter
array a slightly different form
of
the
DIM
statement
is
used
:
DIM
character-variable·name hi
zeJ *length
..
..,here:
character·variable·n
amc
is a
variable name which
conforms
to
the
rules for normal
character
variables
as d iscussc d prtviously
.
size is
the
number of storage
locations and must be
in
the
range
0
th
rough
255.
Note
th
at
when
you specify
a
number, you get one
more location
than you
specified.
*length is
OPtional.
If
used
,
it
specifics
the
length
of each of
the strings
that comprise the
array
.
Length
is
a
number in the range
I to
80.
If
this clause is not used. the strings
will
have the
defoult
length
of
16
characters.
Examples
of
legal
character array declarations are
:
DIM XS (4J
DIM
NMS
(
10)
*
10
DIM INS
(1J*80
DIM
RS
(OJ*
26
The
fi rst example
creates an array
of
five
strings
each
able
to
store 16
charac
ters.
The second
D
IM statement
declares
an array
NM
with
eleven
strings
o
f
10
c
haracters
each
. Explicit
definit
ion
of
Slrings
smaller than
the
dcf-0ult helps to conserve
memory space. The third
example
declares
a
two
clement array
of
80-eht1rac1er strings
and
the
last
e
xample declares a single
string of twenty·
six
c
haracters
(see Section
B.1
.).
Besides
the
simple
arrays
we
have just studied
the PC·1500A
allows
"two-dimensional"
arrays.
By analogy.
a one-dimensional array
is
a
list of data
arranged
in
a
single
column
.
A
two~imen·
sional
array is a
table
of data
\Vith
rows
and columns.
The
t\-•10-dimensionat
array
is
declared by
the
statement
:
..Q!M.
numeric·variable·name (rows.
columns)
.2!..
.Q!M.
character-variable·namc (r-o ..
•1s,
colu1nns) .f.
lc
r1gth
where:
rows
specifies the
number
of rows
in 1he array.
This must be
a number
in
the
range
0
through
255.
Note that
\\ihen
you
specify
the
number
o
f
ro\vs you
get
one
more
row than
the
specification.
columns
specifies
the number
of
columns in
the
array
.
This
must be a
number
in
the
range
0
through
255.
Note
that
when you
specify the number
of columns
you
get one
more
column
than the
specification.
The following diagram illustrates
the storage
locations
that result
from the
declaration
DIM T
(2,
3J and
the
subscripts
(now composed
of two
numbers) which pertain
to
each
storage
locat•on:
colum11
1
column
2
column 3
column 4
T
(0, 0)
T
(O.
1)
T
10,
2
J
T (0
,
3)
<OW
T
(I,
01
T
(1,1J
T
(1,
2)
T
(1,
3J
row
2
T
(2, OJ
T
12.
1)
T
(2.
2J
T (2. 3J
Do not
sale
this PDF
!!!
69

Hide quick links:

Advertisement

Table of Contents
loading

Table of Contents