The $GOTO statement

In addition to the subroutine technique or the use of control block statements ($IF, $FOR...), this functionality offers another option for branching to other program parts. The GOTO command can be called at any point in the NC program by setting jump labels in the NC program.

There are two options to use jump statements:

Expression Label:

N<block_number>:                                                                Definition

$GOTO<Block_number> | $GOTO<expr>                      Jump call

String Label:

[<string>]                                                                               Definition

$GOTO [<string>]                                                                 Jump call

Characteristics:

Programing Example

prg_example

The $GOTO statement

%goto

N05  P1=1

N06  P2=1

N10  G74 X1 Y2 Z3

N11      X0 Y0 Z0

N15  $IF P1==1 $GOTO N40: ;   Jump from outside to N40 in a

                          ;   control block

N20  X10

N25  Y10

N30  $IF P1==2

N35    X20

N40:   $IF P2==1

N45    X30

N50:     Y30 $GOTO N65: ;   Jump to N65 between control block levels

                        ;   IF-ELSE

N51    $ENDIF

N55  $ELSE

N60    Y40

N65:   X40

N70  $ENDIF

N80   Z99

N999  M30

Permitted and impermissible jumps in the $GOTO command
Permitted and impermissible jumps in the $GOTO command

Programing Example

prg_example

N10 G1 XY

N20: X100                              ;Label definition N20:

$IF V.L.dummy_1 <100 $GOTO [N20]         ;Jump to label N20

$IF V.L.dummy_1 >200

$GOTO [LABEL_1]                        ;Jump to label [LABEL_1])

Y20

$ENDIF

[LABEL_1] X0                           ;Label definition [LABEL_1]

N30 A0

$FOR V.P.my_var = 0, 4, 1

$IF V.L.dummy_2 <200 $GOTO [CONTINUE]  ;Jump to label [CONTINUE])

$SWITCH V.P.my_var

$CASE 0

V.P.AXE_X=V.P.GROUP[1].position[V.P.my_var]

$BREAK

$CASE 1

V.P.AXE_Y=V.P.GROUP[1].position[V.P.my_var]

$BREAK

$CASE 2

V.P.AXE_Z=V.P.GROUP[1].position[V.P.my_var]

$BREAK

$CASE 3

V.P.AXE_A=V.P.GROUP[1].position[V.P.my_var]

$DEFAULT

$ENDSWITCH

$ENDFOR

[CONTINUE]                             ;Label definition [CONTINUE]

N1000 ...

...