9 7
96-8000 rev R June 2007
Macros
The M99 conditional construct is unique to the HAAS control. Without macros, M99 in the HAAS control has the
ability to branch unconditionally to any line in the current subroutine by placing a P code on the same line. For
example:
N50 M99 P10;
branches to line N10. It does not return control to the calling subroutine. With macros enabled, M99 can be used
with a conditional expression to branch conditionally. To branch when variable #100 is less than 10 we could code
the above line as follows.
N50 [#100 LT 10] M99 P10;
In this case, the branch occurs only when #100 is less than 10, otherwise processing continues with the next
program line in sequence. In the above, the conditional M99 can be replaced with
N50 IF [#100 LT 10] GOTO10;
Arithmetic Expressions
An arithmetic expression is any expression using variables, operators, or functions. An arithmetic expression returns
a value. Arithmetic expressions are usually used in assignment statements, but are not restricted to them.
Examples of Arithmetic expressions:
#101=#145*#30;
#1=#1+1;
X[#105+COS[#101]];
#[#2000+#13]=0;
Assignment Statements
Assignment statements allow the programmer to modify variables. The format of the assignment statement is:
<expression>=<expression>
The expression on the left of the equal sign must always refer to a macro variable, whether directly or indirectly. The
following macro initializes a sequence of variables to any value. Here both direct and indirect assignments are used.
O0300
(Initialize an array of variables) ;
N1 IF [#2 NE #0] GOTO2
(B=base variable) ;
#3000=1
(Base variable not given) ;
N2 IF [#19 NE #0] GOTO3
(S=size of array);
#3000=2
(Size of array not given) ;
N3 WHILE [#19 GT 0] DO1 ;
#19=#19-1
(Decrement count) ;
#[#2+#19]=#22
(V=value to set array to) ;
END1 ;
M99 ;
The above macro could be used to initialize three sets of variables as follows:
G65 P300 B101. S20 (INIT 101..120 TO #0) ;
G65 P300 B501. S5 V1 (INIT 501..505 TO 1.0) ;
G65 P300 B550. S5 V0 (INIT 550..554 TO 0.0) ;
The decimal point in B101., etc. would be required.
Control Statements
Control statements allow the programmer to branch, both conditionally and unconditionally. They also provide the
ability to iterate a section of code based on a condition.
Summary of Contents for Mill
Page 12: ...96 8000 rev R June 2007 Safety 5 ...
Page 14: ...96 8000 rev R June 2007 Safety 7 LATHE WARNING DECALS ...
Page 15: ...8 Safety 96 8000 rev R June 2007 ...
Page 17: ...10 Introduction 96 8000 rev R June 2007 ...
Page 117: ...110 4 5 Axis Programming 96 8000 rev R June 2007 ...
Page 199: ...Settings 192 96 8000 rev R June 2007 ...