IF .. THEN .. ELSE .. ENDIF
Purpose | To make a decision regarding program flow based on the result returned by an expression. | ||||||||||||
Syntax |
If the result of the expression is non-zero (logical true), the block of program lines between the THEN and the ELSE statements will be executed. If the result of the expression is zero (false), the block between the IF and ELSE will be ignored, and the block between the ELSE and ENDIF statements will be executed instead. If there is no ELSE statement, and if the result of the expression is false, the block of program lines between the THEN and the ENDIF statement will be ignored, but execution will continue right after the ENDIF statement. Nesting of IF statement Statement blocks within the IF..THEN..ELSE statement may contain other IF..THEN..ELSE blocks (nesting). Note that each IF statement must be ended with the ENDIF statement. Otherwise an error message "IF without ENDIF" will be reported during compilation. Testing Equality: Special comparison operators may be used in the expression of the IF statement. Only integer expression may be compared. For comparison of strings, please refer to the "STRCMP(A$, B$)" function.
|
||||||||||||
Examples | IF A >= B*5-20*C OR C=20 |
||||||||||||
Comments: | A few comparison expressions may be linked with logical-AND (AND statement) or logical-OR (OR statement) operator as shown in the above examples. |