376
MACROS
96-8000
June 1999
Expressions
Expressions are defined as any sequence of variables and operators surrounded by the square brackets "[" and
"]". There are two uses for expressions: conditional expressions or arithmetic expressions. Conditional expres-
sions return FALSE (0.0) or TRUE (any non zero) values. Arithmetic expressions use arithmetic operators
along with functions to determine a value.
Conditional Expressions
In the HAAS control, ALL expressions set a conditional value. The value is either 0.0 (FALSE) or the value is
nonzero (TRUE). The context in which the expression is used determines if the expression is a conditional
expression. Conditional expressions are used in the IF and WHILE statements and in the M99 command.
Conditional expressions can make use of Boolean operators to help evaluate a TRUE or FALSE condition.
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 constants, 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>