statement/IF statement/IF NAME IF -- Conditional execution ABBREVIATION None SYNOPSIS IF <expression> THEN <clause> [:ELSE <clause>] FUNCTION IF-THEN lets the computer analyze a BASIC expression preceded by IF and take one of two possible courses of action. If the expression is true, the statement following THEN is executed. This expression may be any BASIC statement. If the expression is false, the program goes directly to the next line, unless an ELSE clause is present. The expression being evaluated may be a variable or formula, in which case it is considered true if nonzero, and false if zero. In most cases, there is an expression involving relational operators (=, <, >, <=, >=, <>, AND, OR, NOT). The ELSE clause, if present, must be in the same line as the IF-THEN part. When an ELSE clause is present, it is executed when the THEN clause isn't executed. In other words, the ELSE clause executes when the IF expression is FALSE. INPUTS <expression> - condition (BASIC expression resulting true or false value <clause> - statements to be executed RESULT If expression (<expression>) is true, statements following the word THEN will be executed and if expression is false, statements following the wo ELSE will be executed. If ELSE is not present, program goes directly to the next line. EXAMPLES THEN +-------+ ! Print ! ! "OK" ! /+-------+ Yes / / IF / +--------+ / X --------! Check: !/ ! X>0? !\ +--------+ \ \ \ ELSE No \ +-------+ \! ! ! End ! +-------+ 50 IF X>0 THEN PRINT"OK":ELSE END Checks the value of X. If X is greater than 0, the THEN clause is executed, and the ELSE clause isn't. If X is not greater than 0, the ELSE clause is executed and the THEN clause isn't. NOTES None BUGS None SEE ALSO None