IF-THEN
The IF-THEN statement is a way of conditionally executing a block if the result of an
expression evaluates to true. The expression must contain one of the relational operators which
allows the expression to be reduced to either true or false. If the expression is true, the THEN
portion of the IF statement is executed. If the expression is false, the next line after the IF-
THEN statement is executed.
Example of General Form:
[any ] (relational) [any ]
If [mathematical] (operator ) [mathematical] Then any action
[expression ] [expression ]
N20 IF P1 LT P2 THEN GOTO 15
N21
Or
N20 IF P1 < P2 GOTO 15
N21
The two statements above accomplish the same thing. If the statement is true, N15 is executed;
if it is false, N21 is executed.
Examples:
IF P1*P3⁄COS[P90] GE TAN[P6] THEN X1
IF P4⁄P3 LT P6 GOTO 25
IF P1 = P2 THEN P4 = P5 - P6
Multiple IF statements can be used to check for multiple conditions.
Example:
IF P36<5 THEN IF P1<>0 THEN M5
Defined, this means if P36 is less than 5 and P1 does not equal 0, shut the spindle off.
Note: The word THEN is optional in all cases.