Using expressions in macros
An arithmetic expression is a list of variables and values with operators which define a value. Typical usage is in variable declarations and assignments.
// Variable declarions
REAL factor = 0.6
REAL value = Tolerance * factor
// Assignments
$Stepover = Tool.Diameter * factor
$factor = 0.75
In addition to using expressions in calculations, you can use logical expressions to make decisions in macros. The decision making statements in PowerMill are IF-ELSE_IF, SWITCH, WHILE, and DO-WHILE. These execute the commands within their code blocks if the result of an expression is true (1). For example:
IF active(Tool.TipRadiused) {
// Things to do if a tip radiused tool.
}
IF active(Tool.TipRadiused) AND Tool.Diameter \< 5 {
// Things to do if a tip radiused tool and the diameter
// is less than 5.
}
You can use any expression to decide whether or not a block of code is performed.
Operators for integers and real numbers
The standard arithmetical operators are available for integers and real numbers.
Operator | Description | Examples |
---|---|---|
+ | addition | 3+5 evaluates to 8 |
- | subtraction | 5-3 evaluates to 2 |
* | multiplication | 5*3 evaluates to 15 |
/ | division | 6/2 evaluates to 3 |
% | modulus. This is the remainder after two integers are divided | 11%3 evaluates to 2 |
^ | to the power of | 2^3 is the same as 222 and evaluates to 8 |
For a complete list of operators, see the HTML page displayed when you select click Help > Documentation > Parameters > Reference > Functions.
Operators for strings
The concatenation (+) operator is available for string.
For example "abc"+"xyz"
evaluates to abcxyz.
You can use this to build strings from various parts, for example:
MESSAGE "The Stepover value is: " + string(Stepover)