IF
Purpose: Logic statement for decision making.
Format: IF x THEN clause [ELSE clause]
Description: x is any expression
clause is a BASIC statement or sequence of statements (separated by commas) or a line number to branch to
If x is true (non zero), the clause following the THEN is executed. If x is false (zero), the clause after the ELSE is executed.
Example:
|
10
|
IF OUT1 THEN START OUT2
|
|
|
20
|
IF AVG( A , B , C ) > 22.4 THEN 30 ELSE 50
|
|
|
30 PRINT “AVERAGE IS ABOVE 22.4"
|
|
|
|
40 END
|
|
|
|
50 PRINT “AVERAGE IS BELOW 22.4"
|
|
|
|
60 END
|
|
|