CNC Simulator Pro

user guide

10.3. Conditional Expressions

Conditional expressions are used for decision making within a macro. They use conditional operators between two variables or arithmetic expressions to decide whether an expression is TRUE or FALSE. Conditional expressions are written inside square brackets.
The operators used by conditional expressions are:
EQ       Equal to
NE       Not equal to
LT        Less than
LE        Less than or equal to
GT       Greater than
GE       Greater than or equal to
AND     And
OR       Or
A conditional expression may look like this:
This will be seen as TRUE when variable 4 is greater than variable 2.
We can also test more than one condition like this:
This expression will be TRUE only when variable 4 is greater than both variable 2 and variable 3.
Conditional expressions are used with conditional variables, loops, and branches.
A conditional variable:
IF[#4EQ3] THEN #2=2
This block says: Set variable 2 to 2 only when variable 4 is 3.
We can use a conditional expression to do a branch (jump) to another block.
IF[#4LE#1] GOTO 100
This block says: Go to block number 100 only if variable 4 is less or equal to variable 1.
And we can do loops using conditional expressions too:
These blocks will loop until #5 is 100.