The GOTO statement enablesProgramDirectly jump to a specific statement execution from the current position, in the form:
Goto label;
The label next to it indicates the statement label. Executing the GOTO statement directly causes the program to jump to the lable mark position.
A label can be declared in most places where variables can be declared. The declaration format is:
Label label;
A tag can be any legal identifier or a value between 0 and 9999. Of course, the GOTO statement and
The label must be valid in the current range. In view of this, a global label cannot be defined in the form program,
Not in the initialization and finalization sections of the unit.
Because the GOTO statement is not conducive to program debugging, and it may cause some unpredictable behavior of the program
We recommend that you use the GOTO statement.
The following is an example of Goto:
Program testgoto; {$ apptype console} {$ R *. res} uses system. sysutils; var I: integer; label 1, 2; begin try 1: writeln ('Enter the value of I: '); readln (I ); if I <> 0 then begin GOTO 1; end; exit; else t on E: exception do writeln (E. classname, ':', E. message); end.