The GOTO statement causes an unconditional branch to a statement prefixed by a label. Syntax: GOTO label The 'label' is an unsigned decimal integer or symbolic name that represents a statement label. The GOTO statement must be within the scope of the label declaration. A GOTO statement that is outside a structured statement cannot jump to a label within that structured statement. A GOTO statement within a routine can branch to a labeled statement in an enclosing block only if the labeled statement appears in the block's outermost level.
1 – Examples
FOR i := 1 TO 10 DO BEGIN IF Real_Array[i] = 0.0 THEN BEGIN Result := 0.0; GOTO 10; END; Result := Result + 1.0/Real_Array[i]; END; 10: Invertsum := Result; This example shows how to use a GOTO statement to exit from a loop. The loop computes the sum of the inverses of the components of the variable 'Real_Array'. If the value of one of the components is 0.0, the sum is set to 0.0 and the GOTO statement forces an exit from the loop.