You may want an IF ...THEN statement to be executed only if several
conditions are true at the same time:
345 IF right<3 AND missed=2 THEN PRINT'"Quite pathetic."
AND can also be used to end a REPEAT...UNTIL loop:
270 UNTIL missed=2 AND right=5
Now the loop only ends after you have both missed two letters and have five
correct -- not a very sensible test!
There is (almost) no limit to the number of conditions, for example you might
have:
270 UNTIL missed=2 OR TIME>2000 OR right>5
Multiple choices
IF... THEN ...ELSE is useful if there are only two alternative choices of action,
but often in a program there may be many more. For example, programs often
contain a menu which allows the user to choose one of a number of actions.
Here is the start of a drawing program which contains a menu:
10 MODE 135
20 PROCmenu
30 END
40 DEFPROCmenu
50 REPEAT
60 CLS
70 PRINT TAB(7,5)"Do you want to:"
80 PRINT TAB(8,9)"1 Load a picture"
90 PRINT TAB(8,12)"2 Save a picture"
100 PRINT TAB(8,15)"3 Draw a picture"
110 PRINT TAB(8,18)"4 End the program"
120 PRINT TAB(7,22)"Your choice, 1 to 4 ";
130 REPEAT
140 response=GET
150 UNTIL response>48 AND response<53
160 choice=response-48
170 ON choice PROCLoad, PROCsave, PROCdraw, PROCmake_sure
180 UNTIL choice=4
190 ENDPROC
(This program is incomplete and gives an error message if you run it.)
C 44