1.6 Program structure
1.6.1 CASE statements
Programming format:
CASE expression OF constant 1 GOTOF LABEL1 … DEFAULT GOTOF LABELn
CASE instruction can jump correspondingly according to the different actual value(INT). CASE instruction detects the value in the expression, and then the program transfers to the destination which the constant is corresponding. If the value of the expression is not in the constant class table, it would determine the jump destination by using DEFAULT instruction. If DEFAULT instruction is not programmed, the block which follows the CASE instruction is the jump target.
Example:
DEF INT VAR1, VAR2
CASE (VAR1+VAR2) OF 7 GOTOF MARK1 9 GOTOF MARK2 DEFAULT GOTOF MARK3
MARK1: G00 X1 Y1
MARK2: G00 X2 Y2
MARK3: G00 X3 Y3
1.6.2 IF statements
Programming format:
IF expression
NC block
ELSE
NC block
ENDIF
IF-ELSE-END block is used for the alternative, if the expression evaluates to TRUE, IF branch program is executed, otherwise the ELSE branch is executed. The ELSE branch can be canceled.
Example:
DEF INT VAR1, VAR2
IF VAR1>VAR2
G00 X1 Y1
ELSE
G00 X2 Y2
ENDIF
IF statements can be nested, nesting can not be more than nine layers.
1.6.3 WHILE statements
Programming format:
WHILE expression
NC block
ENDWHILE
As long as the expression is TRUE, the WHILE loop is executed. To get out of the loop, we need to modify the structure of the value of the expression until it is FALSE.
Example:
DEF REAL HH=9
G01 X0
WHILE HH>0
G91 X=HH
HH=HH-1
ENDWHILE