加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 大数据 > 正文

退出Delphi中的“if”

发布时间:2020-12-15 04:21:55 所属栏目:大数据 来源:网络整理
导读:你可以用break退出while循环. 如何退出if. Delphi中有一种GOTO吗? procedure ...begin if .... then begin here the code to execute if (I want to exit = TRUE) then break or GOTO here the code not to execute if has exited end; here the code to ex
你可以用break退出while循环.

如何退出if.

Delphi中有一种GOTO吗?

procedure ...
begin

  if .... then
    begin

      here the code to execute

      if (I want to exit = TRUE) then
        break or GOTO

      here the code not to execute if has exited

    end;

  here the code to execute

end;

解决方法

您可以使用例外.

在内部if或循环中调用Abort,并在需要继续的地方捕获EAbort异常

procedure ...
begin

 try 
  if .... then
    begin

      (*      here the code to execute  *)

      if I_want-to-exit then Abort;

      (*      here the code not to execute if has exited *)

    end;

   except on E: EABORT do ;
   end;

   (*  here the code to execute *)
end;

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读