18.6.1 goto
The goto statement provides an unconditional jump to a valid label position declared in the same section.
- Organization of this subsection
(1) Format
- Statements
Jump statement Label statement
- Jump statement
goto identifier;
- Label statement
identifier:
(2) Description
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.
(3) Example of coding
//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 }
(4) Notes
For better programming, you should use the break, continue, or return statement rather than the goto statement wherever possible.