in BASIC ROM:
|List of all BASIC keywords|
Typ: Command General Programming-Syntax: IF <equation> THEN <linenumber> or IF <equation> GOTO <linenumber> or IF <equation> THEN <command>
When the condition is true, the BASIC commands after THEN or the GOTO command will be done. When the condition is false then the BASIC interpreter will ignore the rest of the BASIC commands in the line.
For the condition the following relational operators are useful:
- = equal
- <> unequal
- < less than
- > greater
- <= less-equal
- >= greater-equal
10 PRINT CHR$(147); 20 INPUT "2 numbers, please: ";A$, B$ 30 IF A$="" OR B$="" THEN 20 40 A=VAL(A$): B=VAL(B$) 50 IF A>0 THEN PRINT "A is positive and "; 51 IF A<0 THEN PRINT "A is negative and "; 52 IF A=B THEN PRINT "A is equal to B "; 53 IF A<>B THEN PRINT "A is not equal to B "; 54 IF NOT A AND NOT B THEN PRINT ", neither number is -1"; 55 IF A=64 AND B=64 THEN PRINT " !!! BINGO !!!": GOTO 58 56 IF A=B AND A=0 GOTO 58 57 IF (A AND B=0) OR (NOT B AND A=0) THEN END 58 FOR X=0 TO 3000: NEXT 59 GOTO 10
Technically what happens is the expression is evaluated, and if the expression is 0, the statements after THEN or GOTO are not executed. If the expression is non-zero, the statements after THEN or GOTO will be executed. So something like this can be used:
10 IF A THEN PRINT "A is nonzero"