請問變數的位置問題

  •   77 
  • 最後發表   wulongr  2018 二月 06
wulongr 發文於   2018/02/06

請問以下的程式,如果把[if bar_count > 90 then return;] 這行移至下面comment處,結果會不一樣。

想請問XS的變數生命週期是怎麼決定的?謝謝!

 

variable:bar_count(0);

if bar_count > 90 then return;

if date<>date[1] then 

begin

    bar_count=0;

end;

bar_count=bar_count+1;

 //if bar_count > 90 then return;

if bar_count=5 or bar_count=95 then

begin

ret=1;

end;

XQ小幫手 發文於   2018/02/06

你好:

  這是因為你判斷式位置的關係喔,所以會造成此結果。

如果要兩者一致的話,要改為 bar_count >= 90,以上說明。

發表回覆
Close