Use of Delphi goto statements

Source: Internet
Author: User

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.


 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.