delphi 程序执行完了会自动退出···难道会选择最近的Exit?

一个奇怪的问题,当条件为False时,还是掉进了过程里:

  ret:=IsBoxFull(StrToInt(E_BoxNo.Text),RG_Box);
  if ret=true then
  begin
     if Application.MessageBox('该箱表数已满,是否打印条形码!','系统提示',MB_YesNo)=IDYES Then
     begin
        f_Main.CDS_meter.Close();
        f_Main.SQLQ_meter.Params.ParamByName('BoxNo').Value :=StrToInt(E_BoxNo.Text) ;
        f_Main.CDS_meter.Open();
        R_PrintInStorageNumber.Print;
        RB_NewBox.Checked := True ;
        CDS_MaxBoxNo.Close();
        CDS_MaxBoxNo.Open;
        E_BoxNo.Text := IntToStr(CDS_MaxBoxNo['MaxBoxNo']+1);
        f_Main.CDS_meter.Close();
        f_Main.SQLQ_meter.Params.ParamByName('BoxNo').Value := StrToInt(E_BoxNo.Text) ;
        f_Main.CDS_meter.Open();
        E_MeterNo.Text := '';
        E_MeterNo.SetFocus();
        Exit;
     end
     else
     begin
        if Application.MessageBox('该箱表数已满,是否更换新箱号入库!','系统提示',MB_YesNo)=IDYES Then    //需要修改
        Begin
           RB_NewBox.Checked:=True;
           CDS_MaxBoxNo.Close;
           CDS_MaxBoxNo.Open;
           E_BoxNo.Text:=IntToStr(CDS_MaxBoxNo['MaxBoxNo']+1);
           f_Main.CDS_meter.Close();
           f_Main.SQLQ_meter.Params.ParamByName('BoxNo').Value := StrToInt(E_BoxNo.Text) ;
           f_Main.CDS_meter.Open();
           E_MeterNo.Text := '';
           E_MeterNo.SetFocus();
        end
        else
           f_Main.CDS_meter.Close();
           f_Main.SQLQ_meter.Params.ParamByName('BoxNo').Value := StrToInt(E_BoxNo.Text) ;
           f_Main.CDS_meter.Open();
           E_MeterNo.Text := '';
           E_MeterNo.SetFocus();
           Exit;
     end;
  end;

为什么ret=False 了,下面的Exit语句还是执行到了?

要是在exit前面加一个showmessage('OK')会怎样?在前面加了会跳到Exit,在后面加了就不会跳进来了,这个算不算是delphi的隐规则

啊?也许是吧,只是Borland没公布出来。

原文地址:https://www.cnblogs.com/jijm123/p/13771595.html