變數為甚麼會恢復初值呢?

  •   63 
  • 最後發表   風揚  2022 四月 14
風揚 發文於   2022/04/08

請教下面程式為什麼 SendTime 在090500 以後會變成0呢??

不是應該一直是 090500  嗎?  我有什麼辦法可以KEEP 這個數呢?

 

程式:

Var: SendTime(0) ;   { 進場時間 }

if currenttime = 090500  then  SendTime =  currenttime;

Print(file("c:\print\"),"currenttime:",currenttime,"SendTime:",SendTime)   ;

結果:

currenttime: 90430.000000 SendTime: 0.000000 

currenttime: 90445.000000 SendTime: 0.000000 

currenttime: 90500.000000 SendTime: 90500.000000 

currenttime: 90515.000000 SendTime: 0.000000 

currenttime: 90530.000000 SendTime: 0.000000 

currenttime: 90545.000000 SendTime: 0.000000 

currenttime: 90600.000000 SendTime: 0.000000 

currenttime: 90615.000000 SendTime: 0.000000 

 

XQ小幫手 發文於   2022/04/14

Hello 風揚,

 

變數在K棒中改變數值,需要使用IntrabarPersist才能夠將其保存住。

細節可以參考連結裡的說明。

所以您的腳本應該修改為:

Var: intrabarPersist SendTime(0) ;   { 進場時間 }

if currenttime = 090500  then  SendTime =  currenttime;

Print(file("c:\print\"),"currenttime:",currenttime,"SendTime:",SendTime);

發表回覆
Close