The goto statement provides an unconditional jump to a valid label position declared in the same section.
Jump statement
Label statement
goto identifier;
identifier:
The goto statement is used to exit deeply nested loops directly. Unlike this statement, the break statement can exit only one nesting level of repetitive statements.
//MAIN section
MAIN
{
...
...
AIT_LogMessage("LBL030: JUMP TO LABEL");
goto label1;
AIT_LogMessage("LBL030: NOT DISPLAYED 1"); // Not executed
label1: // The control shifts here.
AIT_LogMessage("LBL030: JUMPING TO LABEL "); // Executed
}
For better programming, you should use the break, continue, or return statement rather than the goto statement wherever possible.