Once搭配else用法

  •   242 
  • 最後發表   ItsYeLizard  2021 四月 27
ItsYeLizard 發文於   2021/04/26

請問一下once如何搭配else使用?

例如

once(

condition1 and

condition2) begin

ret =1;

retmsg=...;  end;

else once(

condition3 and

condition4) begin

ret =1;

retmsg=...;  end;

 

 

XQ小幫手 發文於   2021/04/27

Hello ItsYeLizard,

 

您可以改為使用 if 來替代,例如說

variable: first_time(False);

If condition1 and condition2 and not first_time then begin

    ret = 1;

    retmsg = ...;

    end;

else if condition3 and condition4 and not first_time begin

    ret = 1;

    retmsg = ...;

    end;

 

這樣if跟else的部分只會執行一次。

細節您可以參考 Once 連結。

發表回覆
Close