200 DATA3

290 DATAWhich century is this,20th

300 DATAWhich British king had six wives,Henry VIII

310 DATAWhat is the seed of an oak called,Acorn

The READ statement in line 70 makes the computer search through the

program until it finds the first line beginning with the word DATA, which is

280. The computer reads the first value after the word DATA and stores it in

the variable how_many. DATA items can either be numbers or strings, and

are separated by commas.

The loop from lines 120 to 170 is carried out 3 times (the value of how_many).

Line 130 successively reads a question and answer from the DATA statements.

Each time through the loop the computer carries on reading data at the point at

which it left off, so each time it reads a different question and answer.

Any number of data items can be included in a DATA statement, up to the

maximum line length of 255 characters. Thus all the data in the program could

be confined to a single line:

280 DATA3,Which century is this,20th,Which British king had six wiv

es,Henry VIII,What is the seed of an oak called,Acorn

The main reason for breaking the data up is that it makes changes easier. For

similar reasons DATA lines are usually collected together although they can be

placed anywhere within the program. You can add an extra question simply by

inputting these lines:

200 DATA4

310DATAWho won the 1982 World Cup,Italy

Running the program reveals one of the problems of using strings. The

computer only accepts as correct a response that exactly matches its stored

answer -- for example, Henry the Eighth is treated as a wrong answer to

question 2!

You can use the RESTORE statement to make a program read DATA

beginning at a particular line. Add these lines to the quiz program to offer

alternative questions:

91 PRINT "Do you want (1) genera[ knowtedge questions"

92 PRINT TAB(13),(2) questions on animals"

93 INPUT "1 or 2" ,choice

94 IF choice=1 THEN RESTORE 280 ELSE RESTORE 500

500 DATA3

510 DATAWhat is the young of a wolf called,wolverine

520 DATAWhat is the largest mammal,whale

530 DATAWho killed Cock Robin,sparrow

C 5l