Jump statement

LABEL <label_name>;

    <statements>

GOTO <label_name>;

The LABEL- and GOTO statements allow jumps in the G-code.

LABEL <label_name>;

A jump destination with the specified name is included at the specified position using LABEL.
<label_name> must be a valid identifier, like the name of a variable or a function.
A LABEL statement can be used where a statement is expected, except in the context of a CASE statement.
If a LABEL statement is defined in a function, its scope is limited to the function.
If the label statement is in the global code, it is valid only in the global scope.
It is an error if two LABEL statements with the same name are defined in the same scope.

GOTO <label_name>;

Causes the execution of the g-code to continue at the point where the specified LABEL is included.
It is an error if the specified <label_name> is not defined in the scope of the GOTO statement.
In addition, it is not allowed to use GOTO statements within a CASE statement.

Sample

N10 G00 X0 Y0 Z0
N20 G01 X10 F1000
!R1 := 0;

!LABEL jumpPos;
!R2 := R1;
!R1 := R2 + 1;
N30 G01 Y=10*R1

!IF R1 = 1 THEN
    !GOTO jumpPos;
!END_IF

N40 G01 Z =10*r1

!IF R1 = 2 THEN
    !goto jumpPos;
!END_IF

M30

Requirements

TwinCAT

GST Interpreter

TwinCAT 3.1.4024.47

GST 3.1.8.67