Sharp PC-1403 Operation Manual page 88

Hide thumbs Also See for PC-1403:
Table of Contents

Advertisement

82
The
first example
creates
an array
of
five strings,
each
able to store 16
characters.
The
second DIM
statement declares an
array
NM
with eleven strings of 10 characters each.
Explicit
definition
of
strings
smaller than
the
default
helps to conserve memory space.
The third example declares a two-element array of
80-character
strings
and
the last
example declares a singl
e
string
of twenty-six
characters.
Besides the simple
arrays
we have
just
studied,
the computer
allows "two-dimen-
sional"
arrays.
By
analogy,
a
one-dimensional
array
is
a list
of
data
arranged
in
a
single
column.
A
two-dimensional array is a table
of
data with rows and
columns. The
two-dimensional array
is declared by the
statement:
DIM
X$(4)
DIM
NM$(1O)*i0
DIM IN$(1)*80
DIM R$(0)*26
If
the use
of
4 is puzzling, remember
that the numbering
of elements begins
at
zero
and
continues
through
the
size
number
declared
in
the DIM statement.
The
real
power
of arrays lies
in
the
ability to use an expression
or
a variable name
as
a
subscript.
To declare a character
array,
a
slightly
different
form
of the
DIM
statement
is
used:
DIM
character-variable-name (size)
*
length
where:
character-variable-name is a
variabl
e name which conforms to the rules
for
normal
character variables as
discussed
previously.
size
is the
number
of
storage
locations
and
must be in the range Oto
255.
Note
that
when
you
specify
a
number,
you get one more
locati
o
n
than
you
specified.
*length is
optional.
If
used,
it
specifies the length of each of
the
strings
that
compose the
array.
Length
is a
number
in
the range 1 to
80.
If this clause is
not
used,
the strings will
have
the default
length
of 16
characters.
Examples of legal
character
array declarations are:
Concepts
and Terms of BASIC

Hide quick links:

Advertisement

Table of Contents
loading

Table of Contents