FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour Displaying a meter
Posts: 723
Joined: Tue Sep 04, 2007 08:45 AM
Displaying a meter
Posted: Sat Dec 31, 2011 07: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.

Posts: 1091
Joined: Thu Nov 17, 2005 11:08 AM
Re: Displaying a meter
Posted: Sun Jan 01, 2012 08:58 AM
Code (fw): Select all Collapse
#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
Marco Boschi
info@marcoboschi.it
Posts: 368
Joined: Sun May 31, 2009 06:25 PM
Re: Displaying a meter
Posted: Sun Jan 01, 2012 01:12 PM

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

Regards,



André Dutheil

FWH 13.04 + HB 3.2 + MSVS 10
Posts: 723
Joined: Tue Sep 04, 2007 08:45 AM
Re: Displaying a meter
Posted: 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.

Posts: 368
Joined: Sun May 31, 2009 06:25 PM
Re: Displaying a meter
Posted: 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

Continue the discussion