37996-8000
MACROS
June 1999
Conditional Branch (IF and GOTOn)
Conditional branching allows the program to transfer control to another section of code within the same subrou-
tine. Conditional branching can only be used when macros are enabled. The HAAS control allows two similar
methods for accomplishing conditional branching.
IF [<conditional expression>] GOTOn
Here, as discussed above, <conditional expression> is any expression that uses the six Boolean operators
EQ, NE, GT, LT, GE, or LE. The brackets surrounding the expression are mandatory. In the HAAS control, it is
not necessary to include these operators. For example:
IF [#1 NE 0.0] GOTO5;
could also be:
IF [#1] GOTO5 ;
In this statement, if the variable #1 contains anything but 0.0, or the undefined value #0, then branching to
block 5 will occur; otherwise, the next block will be executed. If portability to a control other than HAAS is
desired, then it is recommended that the conditional operators be used.
In the HAAS control, a conditional expression can also be used with the M99 Pnnnn format, providing that
macros have been enabled. An example is as follows:
G0 X0 Y0 [#1EQ#2] M99 P5;
Here, the conditional is for the M99 portion of the statement only. The machine tool is instructed to X0, Y0
whether or not the expression evaluates to TRUE or FALSE. Only the branch, M99, is executed based on the
value of the expression. It is recommended that the IF GOTO version is used if portability is desired.
Conditional Execution (IF THEN)
Execution of control statements can also be achieved by using the IF THEN construct. The format is:
IF [<conditional expression>] THEN <statement>;
Note: To preserve compatibility with FANUC syntax "THEN" may not be used with
GOTOn.