EasyManua.ls Logo

Commodore 128D - Dimensioning Arrays

Commodore 128D
427 pages
Print Icon
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Loading...
lates
the
total,
just
as
it
did
before,
but
you
must
use
a
subscripted
variable
to
do
it.
After
you
run
the
program,
if
you
want
to
recall
the
third
number,
type
?X(3)<RETURN).
The
computer
remembers
every
number
in
the
array
X.
You
can
create
string
arrays
to
store
the
char
acters
in
string
variables
the
same
way.
Try
updating
the
COMMODORE
128
COMPUTER
READ-DATA
program
so
the
computer
will
remember
the
elements
in
the
A$
array.
5
DIM
A$(3)
10FORJ-1
TO
3
20
READ
A$(J)
30 ?
A$(J)
40
NEXT
50
END
60
DATA
COMMODORE,C128,COMPUTER
TIP:
You
do
not
need
the
DIM
statement
in
your
program
unless
the
array
you
use
has
more
than
10
elements.
See
DIMENSIONING
ARRAYS.
Dimensioning
Arrays
can
be
used
with
nested
loops,
so
the
Arrays
computer
can
handle
data
in
a
more
advanced
way.
What
if
you
had
a
large
chart
with
10
rows
and
5
numbers
in
each
row.
Suppose
you
wanted
to
find
the
average
of
the
five
numbers
in
each
row.
You
could
create
10
arrays
and
have
the
computer
calculate
the
average
of
the
five
numbers
in
each
one.
This
is
not
necessary,
because
you
can
put
all
the
numbers
in
a
two-
dimensional
array.
This
array
would
have
the
same
dimensions
as
the
chart
of
numbers
you
want
to
work
with—10
rows
by
5
columns.
The
DIM
statement
for
this
array
(we
will
call
it
array
X)
should
be:
10
DIM
X(10,5)
This
tells
the
computer
to
reserve
space
in
its
memory
for
a
two-dimensional
array
named
X.
The
computer
reserves
enough
space
for
50
numbers.
You
do
not
have
to
fill
an
array
with
as
many
numbers
as
you
DIMensioned
it
for,
but
the
computer
will
still
reserve
enough
space
for
all
of
the
positions
in
the
array.
62
USING
C128
MODE—Advanced
BASIC
Programming

Table of Contents

Other manuals for Commodore 128D

Related product manuals