Index meter (Solved)

Index meter (Solved)

Postby HunterEC » Thu Oct 18, 2012 9:08 pm

Guys:

I used to use a "generic" function to create index TAGs (DBFCDX driver). Sort like this:

Code: Select all  Expand view
FUNCTION CreateTag (cTagName, cKey, cCondition, lDescend)
   PRIVATE cKeyField, cForCond

    INDEX ON &cKeyField TAG (cTagName) FOR &cForCond

RETURN (NIL)
 


How can I add / display a meter showing the index creation progress ?
Last edited by HunterEC on Fri Oct 19, 2012 8:00 pm, edited 1 time in total.
HunterEC
 
Posts: 723
Joined: Tue Sep 04, 2007 8:45 am

Re: Index meter.

Postby Enrico Maria Giordano » Thu Oct 18, 2012 9:19 pm

Try using MsgMeter() function.

EMG
User avatar
Enrico Maria Giordano
 
Posts: 8315
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

Re: Index meter.

Postby ADutheil » Thu Oct 18, 2012 9:23 pm

Hera is the way I do:
Code: Select all  Expand view

MsgMeter( { | oMeter, oText, oDlg, lEnd | ;
   Indexar( oMeter, oText, oDlg, @lEnd, "CODI + PROD + NOME", { || CODI + PROD + NOME }, "ENT_CODI" ) },;
   "Indexando destinatários por produto ...", "aguarde", .F. )
     
FUNCTION Indexar( oMeter, oText, oDlg, lEnd, cChav, bBlok, cIndx, lUnic, lDesc, cFor, bFor, cBag )
IF empty( cFor )
   cFor := if( "SINC" $ cChav, NIL, "!deleted()" )
   bFor := if( "SINC" $ cChav, NIL, { || !deleted() } )
ENDIF
cBag := if( cBag == NIL, NIL, cBag )
lUnic := if( lUnic == NIL, .F., lUnic )
lDesc := if( lDesc == NIL, .F., lDesc )
oMeter:nTotal := lastRec()
ordSetFocus( 0 )
ordCondSet( cFor, bFor,,, { || ( oMeter:Set( RecNo() ), SysRefresh(), ! lEnd ) }, , recno(),,,, lDesc )
ordCreate( cBag, cIndx, cChav, bBlok, lUnic )
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

Re: Index meter.

Postby HunterEC » Thu Oct 18, 2012 11:38 pm

André:

Thank you very much for your response. Here is what I did, the dialog shows but the meter never displays. Any clues ?
Code: Select all  Expand view

      MsgMeter ( { | oMeter, oText, oDlg, lEnd | ;
                CreateTag( oMeter, oText, oDlg, @lEnd, "Test", "TagName", "Test_key",;
                          "! EMPTY(Tesk_key)", {|| ! EMPTY(Test_key)})}, ;
                "Procesando ...", "Un Momento Por Favor ..." )

PROCEDURE CreateTag (oMeter, oText, oDlg, lEnd, cOrderBag, cTagName, cKey, ;
                            cForCond, bForCond, lDescend)
   *
   * This PROCEDURE creates index TAGs.
   *
   DEFAULT lDescend   TO .F.
   DEFAULT cOrderBag  TO ALIAS()
   DEFAULT bForCond   TO {|| .T.}

   oMeter:nTotal := LASTREC()

   ORDSETFOCUS(0)
   DBGOTOP()

   IF cForCond != NIL
      ORDCONDSET(cForCond, bForCond, , , {|| ( oMeter:Set( RECNO() ), ;
                 SysRefresh(), ! lEnd )}, , RECNO(), , , , lDescend)
   ENDIF
   ORDCREATE(cOrderBag, cTagName, cKey)
RETURN
 


FiveWin 10.06 xHarbour: xBuild Wizard Version: 4.5 Dates Aug 3 2010 05:26:24

Obrigado !
HunterEC
 
Posts: 723
Joined: Tue Sep 04, 2007 8:45 am

Re: Index meter.

Postby Rick Lipkin » Fri Oct 19, 2012 12:38 pm

Consider this code .. been using this since the early days of FW..

Rick Lipkin

Code: Select all  Expand view

//----------------------------
FUNC INDEX_USER()

LOCAL cDEFA := SET(7)

FERASE( cDEFA+"\USERINFO.CDX" )
SELECT 1
IF NETUSE( "USERINFO.DBF",.T.,5)

   IndexMeter( { | oMeter, oText, oDlg, lEnd |            ;
        BuildUser( oMeter, oText, oDlg, @lEnd, 1 ) }    , ;
        ALIAS()+".dbf tag Userid " )

   CLOSE DATABASES
ENDIF

RETURN(NIL)

//-------------------------------------------------------------//
FUNCTION BuildUser( oMeter, oText, oDlg, lEnd, nTAG )

   oMeter:nTotal := lastrec()

   DO CASE
   CASE nTAG = 1
        INDEX on userid TAG userid                           ;
              EVAL ( oMeter:Set( recno() ), SysRefresh(), !lEnd )
   ENDCASE

RETURN( NIL )

 
User avatar
Rick Lipkin
 
Posts: 2615
Joined: Fri Oct 07, 2005 1:50 pm
Location: Columbia, South Carolina USA

Re: Index meter.

Postby HunterEC » Fri Oct 19, 2012 2:30 pm

Rick:

Thank you for your response. I used your code and have the code below in place as the IndexMeter function (courtesy of a fellow forum member (Uwe)), still no meter shows.
Code: Select all  Expand view

FUNC INDEX_USER()

   LOCAL cDEFA := SET(7)

   IndexMeter( { | oMeter, oText, oDlg, lEnd |            ;
        BuildUser( oMeter, oText, oDlg, @lEnd, 1 ) }    , ;
        ALIAS()+".dbf tag user id " )
RETURN(NIL)

//-------------------------------------------------------------//
FUNCTION BuildUser( oMeter, oText, oDlg, lEnd, nTAG )

   oMeter:nTotal := LASTREC()

   DO CASE
   CASE nTAG = 1
        INDEX on Id TAG UserId                             ;
              EVAL ( oMeter:Set( recno() ), SysRefresh(), !lEnd )
   ENDCASE

RETURN( NIL )

FUNCTION IndexMeter ( bAction, cMsg, cTitle )
   LOCAL oDlg, oMeter, oText, lEnd := .F., nVal := 0

   DEFAULT bAction := { || nil }, cMsg := "Processing...", cTitle := ""

   DEFINE DIALOG oDlg FROM 5, 5 TO 11, 65 TITLE cTitle ;
   STYLE nOr( WS_POPUP,WS_CAPTION,WS_THICKFRAME )

   @ 0.2, 0.5  SAY oText VAR cMsg SIZE 130, 10 OF oDlg

   @ 1,   0.5  METER oMeter VAR nVal SIZE 150, 10 OF oDlg

   *  @ 2.5, 9.5  BUTTON "&Cancel" OF oDlg SIZE 32, 13 ACTION lEnd := .t.

   // This block gets evaluated only the first time the DialogBox is painted !!!
   oDlg:bStart := { || Eval( bAction, oMeter, oText, oDlg, @lEnd ), lEnd := .T., oDlg:End() }

   ACTIVATE DIALOG oDlg CENTERED VALID lEnd

RETURN(NIL)
 


Any clues ? Thank you



Gustavo
HunterEC
 
Posts: 723
Joined: Tue Sep 04, 2007 8:45 am

Re: Index meter.

Postby Enrico Maria Giordano » Fri Oct 19, 2012 2:57 pm

Please look at samples\testmmt.prg sample.

EMG
User avatar
Enrico Maria Giordano
 
Posts: 8315
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

Re: Index meter.

Postby ADutheil » Fri Oct 19, 2012 3:14 pm

Drop this line IF cForCond != NIL and its ENDIF conterpart. If cForCond is NIL oMeter:Set( RECNO() ) will not be refreshed.
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: Index meter.

Postby HunterEC » Fri Oct 19, 2012 5:36 pm

André:

I dropped the IF .. ENDIF and still the meter does not show.

Code: Select all  Expand view

IndexMeter (  { | oMeter, oText, oDlg, lEnd | BuildTag( oMeter, oText, oDlg, @lEnd, "TEST",;
                          "UserId", "Id", "! EMPTY(Id)", {|| ! EMPTY(Id) } ) },  ;
                          "Mantenimiento ...", "Un Momento Por Favor ..." )

FUNCTION IndexMeter ( bAction, cMsg, cTitle )
   LOCAL oDlg, oMeter, oText, lEnd := .F., nVal := 0

   DEFAULT bAction := { || nil }, cMsg := "Processing...", cTitle := ""

   DEFINE DIALOG oDlg FROM 5, 5 TO 11, 65 TITLE cTitle ;
   STYLE nOr( WS_POPUP,WS_CAPTION,WS_THICKFRAME )

   @ 0.2, 0.5  SAY oText VAR cMsg SIZE 130, 10 OF oDlg

   @ 1,   0.5  METER oMeter VAR nVal SIZE 150, 10 OF oDlg

   *  @ 2.5, 9.5  BUTTON "&Cancel" OF oDlg SIZE 32, 13 ACTION lEnd := .t.

   // This block gets evaluated only the first time the DialogBox is painted !!!
   oDlg:bStart := { || Eval( bAction, oMeter, oText, oDlg, @lEnd ), lEnd := .T., oDlg:End() }

   ACTIVATE DIALOG oDlg CENTERED VALID lEnd

RETURN (NIL)


PROCEDURE BuildTag (oMeter, oText, oDlg, lEnd, cOrderBag, cTagName, cKey,  cForCond,;
                                 bForCond, lDescend)
   DEFAULT lDescend   TO .F.
   DEFAULT cOrderBag  TO ALIAS()
   DEFAULT cForCond   TO ".T."
   DEFAULT bForCond   TO {|| .T.}

   oMeter:nTotal := LASTREC()

   ORDSETFOCUS(0)
   DBGOTOP()

   ORDCONDSET(cForCond, bForCond, , , {|| ( oMeter:Set( RECNO() ), SysRefresh(), ! lEnd )}, ;
                        , RECNO(), , , , lDescend)
   ORDCREATE(cOrderBag, cTagName, cKey)
RETURN
 
HunterEC
 
Posts: 723
Joined: Tue Sep 04, 2007 8:45 am

Re: Index meter.

Postby HunterEC » Fri Oct 19, 2012 6:03 pm

André, Enrico, Rick:

Thank you all guys for yor tips. All of them worked. Problem: database driver (SIX). This one has a bug with meters. I tried the same code with DBFCDX and it worked flawlessly. Time to contact xHarbour.


Gustavo
HunterEC
 
Posts: 723
Joined: Tue Sep 04, 2007 8:45 am


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 50 guests

cron