Sinclair QL Beginner's Manual page 92

Hide thumbs Also See for QL:
Table of Contents

Advertisement

Assuming DATA statements with 30 names, a suitable way to place the names in the flats is:
120 FOR floor = 0 TO 2
130
FOR num = 0 TO 9
140
READ flats$(floor,num)
150
END FOR num
160 END FOR floor
You also need a DIM statement:
20 DIM flat$(2,9,8)
which shows that the first subscript can be from 0 to 2 (floor number) and the second subscript can be
from 0 to 9 ( room number). The third number states the maximum number of characters in each array
element.
We add a print routine to show that the golfers are in the flats and we use letters to save space.
100 REMark 30 Golfers
110 DIM flat$(2,9,8)
120 FOR floor = 0 TO 2
130
FOR num = 0 TO 9
140
READ flat$(floor,num) : REMark Golfer goes in
150
END FOR num
160 END FOR floor
170 REMark End of input
180 FOR floor = 0 TO 2
190
PRINT "Floor number" ! Floor
200
FOR num = 0 TO 9
210
PRINT 'Flat' ! num ! flat$(floor,num)
220
END FOR num
230 END FOR floor
240 DATA "A","B","C","D","E","F","G","H","I","J"
250 DATA "K","L","M","N","O","P","Q","R","S","T"
260 DATA "U","V","W","X","Y","Z","@","£","$","%"
The output starts:
Floor number 0
Flat 0 A
Flat 1 B
Flat 2 C
And continues giving the thirty occupants.

Advertisement

Table of Contents
loading

Table of Contents