Guys:
How can I display a meter and update it when my program is working in a long, tedious DO..WHILE loop ? Thank you.
Guys:
How can I display a meter and update it when my program is working in a long, tedious DO..WHILE loop ? Thank you.
#include "fivewin.ch"
FUNCTION MAIN()
LOCAL oDlg
LOCAL oMeter
LOCAL nActual := 0
LOCAL nTotal := 10000
LOCAL oButton
DEFINE DIALOG oDlg
@ 1 , 1 BUTTON oButton PROMPT "Start Meter" ACTION ( nActual := 0 , ;
startloop( oMeter , nActual, nTotal ) )
@ 3 , 1 METER oMeter VAR nActual TOTAL nTotal OF oDLg SIZE 140 , 10
ACTIVATE DIALOG oDlg ON INIT oMeter:settotal( nTotal )
RETURN NIL
FUNCTION STARTLOOP( oMeter, nActual, nTotal )
LOCAL i := nActual
DO WHILE i <= nTotal
oMeter:set( i )
i ++
ENDDO
RETURN NILDid you try MsgMeter( <bAction> [,<cMsg>] [,<cTitle>] ) function?
Marco:
Thank you for the example. I grabbed the concept.
ADutheil:
Thank you for your suggestion. Can you post a working example ? Thank you.
FUNCTION Main
...
...
;;;
MsgMeter( { | oMeter, oText, oDlg, lEnd | YourFunctionHere( oMeter, oText, oDlg, @lEnd ) }, "doing whatever you asked ...", "Wait for the result...", .f. )
...
...
RETURN NIL
FUNCTION YourFunctionHere( oMeter, oText, oDlg, lEnd )
LOCAL nTimes := 0
oMeter:nTotal := areainuse->( lastec() ) // the total items your are going to process. May be len( aRray) .or area->( ordKeyCount() )...
areainuse->( dbGoTop() )
WHILE areainuse->( !eof() )
oMeter:Set( ++nTimes )
SysRefresh()
.....
......
... your code.......
.......
......
areainuse->( dbSkip() )
ENDDO
RETURN NIL