[InstallScript Language Reference]goto

来源:互联网 发布:mac双系统引导修复win 编辑:程序博客网 时间:2024/05/22 03:11

The goto keyword is used to branch directly to the statement immediately following a specified label. In the following code fragment, the goto statement causes execution to continue with the AskText statement.

 

Name: 
AskText("Company name:", "", szSrc); 
if (szSrc = "") then 
    MessageBox("Please enter the company name.", SEVERE); 
    goto Name; 
endif;

 

A goto statement in the main program must specify a label that has been declared in the main program. A goto statement in a function must specify a label that has been declared in that function.

 

InstallScript supports a special form of the if statement that can be used only with goto statements:

 

   if condition goto labelname;

 

This special structure is has the following features:

  • The condition must be followed by a goto statement.

  • The keyword then is not used.

  • The keyword endif is not used.

 

In the following example, the user will be prompted to enter a company name as long as szSrc is a null string (“”).

 

     Name: 
      AskText("Company name:", "", szSrc); 
      if (szSrc = "") goto Name; 
原创粉丝点击