Conditions

A REPEAT ...UNTIL loop can be set so that it ends under a variety of

conditions:

10 MODE 135

20 PROCreaction

30 PROCtest

40 PROCcomment

50 END

60 DEFPROCreaction

70 PRINT TAB(0,8)"Press the correct key when it is"

80 PRINT"flashed on the screen. "

90 PRINT TAB(0,13)"You have 2 seconds to respond, and you"

100 PRINT" can continue until you miss twice or"

110 PRINT"20 seconds is up."

120 PRINT TAB(0,24)"Press any key when you're ready.";

130 key=GET

140 ENDPROC

150 DEFPROCtest

160 CLS

170 missed=0

180 right=0

190 TIME=0

200 REPEAT

210 Letter=RND(26)+64

220 PRINTTAB(19,11)CHR$(letter)

229 REM VDU? gives a bleep

230 VDU 7

240 response=INKEY(200)

250 IF response=l THEN missed=missed+1

260 IF response letter THEN right=right+1

270 UNTIL missed=2 OR TIME>2000

280 ENDPROC

290 DEFPROCcomment

300 CLS

310 PRINT"You got " ; right;" right"

320 PRINT"You missed " ;missed

330 IF right>10 THEN PRINT'''A very good result."

340 IF right<4 THEN PRINT' "Rather poor. "

350 ENDPROC

The loop runs from 200 to 270, and ends either when two keys are missed or 20

seconds is up. The OR can also be used in IF ...THEN statements:

325 IF right>10 OR missed=0 THEN PRINT'''A very good result."

C 43