Commodore VIC-20 Programmer's Reference Manual page 33

Hide thumbs Also See for VIC-20:
Table of Contents

Advertisement

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

Hide quick links:

Advertisement

Table of Contents
loading

Table of Contents