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

0 (0)
Article Rating (No Votes)
Rate this article
Attachments
There are no attachments for this article.
Comments
There are no comments for this article. Be the first to post a comment.
Full Name
Email Address
Security Code Security Code
Related Articles RSS Feed
4.2 System parameter
Viewed 3696 times since Fri, Aug 26, 2016
2.8 Feedrate: G94,G95,G96,G97
Viewed 33891 times since Thu, Aug 25, 2016
1.8 G function group
Viewed 2407 times since Thu, Aug 25, 2016
5.3.5 Thread cutting CYCLE97
Viewed 6890 times since Fri, Aug 26, 2016
3.1 Tool T
Viewed 1979 times since Fri, Aug 26, 2016
5.3.6 Copy cutting CYCLE99
Viewed 5699 times since Fri, Aug 26, 2016
5.2.9 Reaming 2 (boring 5) CYCLE89
Viewed 1963 times since Fri, Aug 26, 2016
1.3 Subroutine
Viewed 2392 times since Thu, Aug 25, 2016
3.4 Tool group TGROUP
Viewed 1948 times since Fri, Aug 26, 2016
5.3.1 Groove CYCLE93
Viewed 4248 times since Fri, Aug 26, 2016