Array Variables - Sharp PC-1403 Operation Manual

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

Advertisement

81
X(4)
=
8
The
first
statement
creates
an array
X
with 6 storage locations.
The
second statement
creates an array AA with
25
locations.
The
third
statement creates
an array with one
location and is
actually
rather
silly
since
(for numbers at
least),
it
is the
same
as
declaring a single-value
numeric
variable.
It is
important
to
know that array variable X
and variable
X
are
separate,
and unique to
SHARP.
The
first
X denotes
a
series of numeric
storage
locations,
and
the
second
a
single and
ditterent
location.
Now that
you
know how to create
arrays, you
might be
wondering how
to refer
to each
storage
location.
Since the entire
group has
only one name,
the way
in
which we
refer
to a
single location (called an
"element")
is to follow the group
name
with
a
number in
parentheses.
This number is
called
"subscript".
Thus,
for
example,
to
store the
number 8
into the fifth
element
of our array X
(declared previously), we
would
write:
DIM X(5)
DIM AA(24)
DIM
05(0)
numeric-variable-name
is a
variable name which
conforms to the normal rules for
numeric variable names
previousl
y discussed.
size
is the
number
of
storage l
o
cations
and must
be
a
number
in the range
0
through
255. Note that
when you specify a
number
for the size,
you
get one
more
location
than you
specified.
Examples of legal numeric
DIMension
statements
are:
Array Variables
For some
purposes,
i1 is useful to
deal with
numbers
as
an
organized
group,
such
as a
list
of
scores
or
a
lax tabl
e
.
In BASI
C
these groups are
called
arrays.
An
array
can
be
either one-dimensional, like a
list,
or
two-dimensional,
like
a
table.
To
define an
array,
the DIM
(short for dimension)
statement
is
used.
Arrays
must
always
be
"declared" (defined)
before they
are
used
(no1 like
the
single-value
variables we
have
been
using). The form for
the
numeric
DIMension statement is:
DIM
numeric-variable-name (size)
where:
Notes: •
The functions and
BASIC commands inherent
to the computer are not
usable as variable
names.
e.g.,
Pl,
IF,
TO,
ON,
SIN,
etc.
Each simple character
variabl
e
can
hold up to 16
characters
and
symbols.
Concepts and Terms of BASIC

Hide quick links:

Advertisement

Table of Contents
loading

Table of Contents