108 55 PRINT A$,X 60 NEXT X 70 PRINT "THE MONTH IS ";A$ 100 DATA JANUARY,FEBRUARY,MARCH,APRIL 110 DATA MAY,JUNE,JULY,AUGUST,SEPTEMBER 120 DATA OCTOBER,NOVEMBER,DECEMBER > >RUN GIVE THE MONTH AS A NUMBER ?6 JANUARY 1 FEBRUARY 2 MARCH 3 APRIL 4 MAY 5 JUNE 6 THE MONTH IS JUNE This is one way of getting to the (say) sixth element of a list but there is another way of using an array. Sometimes there is more than one set of data and it is useful to be able to set the ‘data pointer’ to a selected set of data. The next program has two sets of data each containing a set of prices and car names. One set of data refers to British Leyland cars and the other to Lotus cars.
10 REPEAT 20 PRINT "DO YOU PREFER BL OR LOTUS CARS?" 30 A$=GET$ 40 PRINT A$ 50 IF A$="B" THEN RESTORE 170 ELSE RESTORE 270 60 INPUT "HOW MUCH ARE YOU WILLING TO SPEND ",P 80 PRINT "IN THAT CASE, YOU CAN AFFORD THESE:" 90 FOR X=1 TO 8 100 READ NAME$ 110 READ PRICE 120 IF PRICE 130 NEXT X 140 PRINT 150 UNTIL FALSE 160 170 REM BRITISH LEYLAND CARS 180 DATA MINI 1000 CITY, 3198 190 DATA METRO HLE, 4699 200 DATA MAESTRO 1.3L, 5419