85 10 K=6 20 IF K=6 THEN K=9: PRINT "K WAS 6" ELSE PRINT "K WAS NOT 6": PRINT "END OF LINE" >RUN K WAS 6 (Note that line 20 was so long that it overflowed on the printer but it is all part of line 20.) Changing line 10 to K=7 causes the computer to execute everything after the ELSE and as a result it prints K WAS NOT 6 END OF LINE IF...THEN is often used with more complicated conditions involving the words AND , OR and NOT . For example: IF X=5 AND Y=6 THEN PRINT "GOOD" IF X=5 OR Y=6 THEN PRINT "TOO LARGE" The word NOT reverses the effect of a condition, thus IF NOT (X=6) THEN PRINT "X NOT 6" These are powerful features which are easy to use.
For the slightly more advanced It was explained above that you can use multiple statement lines with IF...THEN but this leads to messy programs. It is far better to use procedures if you want a whole lot of things to occur. Thus: 100 IF H=F*G THEN PROCGOOD ELSE PROCBAD This helps to keep the program readable which is very important, not just from an aesthetic point of view but from the very practical point that a readable program is much easier to get right! More on TRUE and FALSE In chapter 14 the concept of TRUE and FALSE was introduced. A variable can have a numeric value (eg 6 or 15) or it can be TRUE or FALSE .
In fact this is just playing with words (or perhaps we should say numbers) since the computer understands TRUE to have the value -1 and FALSE to have the value 0. 10 IF 6=6 THEN PRINT "YES" ELSE PRINT "NO" >RUN YES