380
MACROS
96-8000
June 1999
This format is traditionally used for conditional assignment statements such as:
IF [#590 GT 100] THEN #590=0.0 ;
Here, variable #590 is set to zero when the value of #590 exceeds 100.0. In the HAAS control, if a conditional
evaluates to FALSE (0.0), then the remainder of the IF block is ignored. This means that control statements
can also be conditioned so that we could write something like:
IF [#1 NE #0] THEN G1 X#24 Y#26 F#9 ;
This executes a linear motion only if variable #1 has been assigned a value. You might try something like this:
IF [#1 GE 180] THEN #101=0.0 M99 ;
This says that if variable #1 (address A) is greater than or equal to 180, then set variable #101 to zero and
return from the subroutine.
Here is an example of an IF statement that branches if a variable has been initialized to contain any value.
Otherwise, processing will continue and an alarm will be generated. Remember, when an alarm is generated,
program execution is halted.
N1 IF [#9NE#0] GOTO3 (TEST FOR VALUE IN F) ;
N2 #3000=11(NO FEED RATE) ;
N3 (CONTINUE) ;
Iteration/Looping (WHILE DO END)
Essential to all programming languages is the ability to execute a sequence of statements a given number of
times or to loop through a sequence of statements until a condition is met. Traditional G coding allows this with
the use of the L address. A subroutine can be executed any number of times by using the L address.
M98 P2000 L5 ;
This is limited since you can not terminate execution of the subroutine on condition. Macros allows more
flexibility with the WHILE-DO-END construct. The syntax is as follows:
WHILE [<conditional expression>] DOn ;
<statements> ;
ENDn ;