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
5.2.7 Boring with stop 1 (boring pass 3) CYCLE87
Viewed 2131 times since Fri, Aug 26, 2016
5.2.1 Drilling, centering CYCLE81
Viewed 13686 times since Fri, Aug 26, 2016
5.2.4 Rigid tapping CYCLE84
Viewed 3471 times since Fri, Aug 26, 2016
2.10 Dwell Time: G04
Viewed 2413 times since Thu, Aug 25, 2016
3.2 Tool offset number D
Viewed 1994 times since Fri, Aug 26, 2016
5.2.3 Deep-hole drilling CYCLE83
Viewed 14221 times since Fri, Aug 26, 2016
2.9 Exact stop/continuous-path control mode: G09/G60/G64
Viewed 3315 times since Thu, Aug 25, 2016
1.3 Subroutine
Viewed 2392 times since Thu, Aug 25, 2016
5.3.4 Thread undercut CYCLE96
Viewed 6662 times since Fri, Aug 26, 2016
5.2.2 Drilling, counterboring CYCLE82
Viewed 2805 times since Fri, Aug 26, 2016