EasyManua.ls Logo

Commodore VIC-20 - Page 33

Commodore VIC-20
308 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...
DIM
Format;
DIM
variable
(
number.
[variable
(
Abbreviation:
lull1
.
. . ,
number),
number,
.
.
. ,
number),
.
Screen
D
â– â– ]
Display:
This
statement
defines
an
array
or
matrix
of
variables,
which
allows
you
to
use
the
variable
name
with
a
subscript.
The
subscript
points
to
the
element
in
the
array
being used.
The
lowest
element
number
in
an
array
is
zerot
and
the
highest
is
the
number
given
in
the
DIM
statement.
If
an
array
variable
is
used
without
a
DIM
statement
to
create
it.
it
is
automatically
DIMensioned
to
10
in
each
dimension.
Let's
suppose
we
wanted
to
keep
track
ot
the
score
of
a
football
game.
There
are
2
teams,
and
four
quarters
plus
a
possible
overtime
quarter
in
the
game.
We
could
use
a
matrix
to
hold
the
scores
fn
each
quarter.
Here
is
a
program
that
asks
you
for
the
score
of
each
team
in
each
quarter:
EXAMPLE:
100
DIM
S(1,5)
,
T$(1)
110
INPUT
"TEAM
NAMES1'
;
T$(0),
T$(1)
120
FOR
Q
-
1
TO
5
130
FOR
T -
0
TO
1
140
PRINT
TS(T),
"SCORE
IN
QUARTER" Q
150
INPUT
S(T,Q)
160S(T,0)
=
S(T,
0)
+
S(Tr
Q)
170
NEXTT,Q
180
PRINT
CHRS(147)
"SCOREBOARD"
190
PRINT
"QUARTER11;
200
FOR
Q
=
1
TO
5
210
PRINT
TAB(CT2
+9)
O;
220
NEXT
230
PRINT
TAB
(15)
"TOTAL"
240
FOR
T
=
0
TO
1
250
PRINT
TS(T);
260
FOR
Q
=
1
TO
5
270
PRINT
TAB
(Q*2
+9)
S(T.
Q);
280
NEXT
290
PRINT
TAB(15)
S(T.O)
300
NEXT

Other manuals for Commodore VIC-20

Related product manuals