Foxpro中的计时器(如何暂停和控制时间)

时间:2013-08-19 19:03:12

标签: timer foxpro visual-foxpro

我运行此代码:

1.THIS.ENABLED = .F.     && suspend timer
2.
3.lnTotFiles = ADIR(laFiles, "*.ERA")
4.FOR lnCntFiles = 1 TO lnTotFiles
5.     DO myprocess WITH laFiles[lnCntFiles,1]
6.     IF THISFORM.cmdPause.CLICK()
7.          MESSAGEBOX("Click OK to resume processing")
8.     ENDIF
9.NEXT lnCntFiles
10.
11.THIS.ENABLED = .T.   && reactivate timer

问题是,Timer事件中的THISFORM.cmdPause.CLICK()始终返回.T。我是否点击暂停命令按钮。

cmdPause.CLICK()包含以下内容:

1.IF THISFORM.cmdPause.CAPTION = "Pause"
2. THISFORM.cmdPause.CAPTION = "Resume"
3. THISFORM.tmrChkDir.ENABLED = .F. 
4.ELSE 5. THISFORM.cmdPause.CAPTION = "Pause" 
6. THISFORM.tmrChkDir.ENABLED = .T. 
7.ENDIF 

那么我应该如何测试Timer事件中FOR-NEXT循环中是否单击了暂停按钮?

1 个答案:

答案 0 :(得分:2)

试试这个:

THIS.ENABLED = .F.     && suspend timer
lnTotFiles = ADIR(laFiles, "*.ERA")
FOR lnCntFiles = 1 TO lnTotFiles
DO myprocess WITH laFiles[lnCntFiles,1]
DOEVENTS     
DO WHILE .T.
IF THISFORM.cmdPause.ENABLED
EXIT
ENDIF
DOEVENTS
ENDDO
NEXT lnCntFiles
THIS.ENABLED = .T.   && reactivate timer