Displaying a meter

Displaying a meter

Postby HunterEC » Sat Dec 31, 2011 7:44 pm

Guys:

How can I display a meter and update it when my program is working in a long, tedious DO..WHILE loop ? Thank you.
HunterEC
 
Posts: 723
Joined: Tue Sep 04, 2007 8:45 am

Re: Displaying a meter

Postby MarcoBoschi » Sun Jan 01, 2012 8:58 am

Code: Select all  Expand view
#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 NIL
User avatar
MarcoBoschi
 
Posts: 1065
Joined: Thu Nov 17, 2005 11:08 am
Location: Padova - Italy

Re: Displaying a meter

Postby ADutheil » Sun Jan 01, 2012 1:12 pm

Did you try MsgMeter( <bAction> [,<cMsg>] [,<cTitle>] ) function?
Regards,

André Dutheil
FWH 13.04 + HB 3.2 + MSVS 10
ADutheil
 
Posts: 368
Joined: Sun May 31, 2009 6:25 pm
Location: Salvador - Bahia - Brazil

Re: Displaying a meter

Postby HunterEC » Sun Jan 01, 2012 10:22 pm

Marco:

Thank you for the example. I grabbed the concept.

ADutheil:

Thank you for your suggestion. Can you post a working example ? Thank you.
HunterEC
 
Posts: 723
Joined: Tue Sep 04, 2007 8:45 am

Re: Displaying a meter

Postby ADutheil » Sun Jan 01, 2012 10:48 pm

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
Regards,

André Dutheil
FWH 13.04 + HB 3.2 + MSVS 10
ADutheil
 
Posts: 368
Joined: Sun May 31, 2009 6:25 pm
Location: Salvador - Bahia - Brazil


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 40 guests