May I have an sample for TProgress for Index

Post Reply
User avatar
dutch
Posts: 1395
Joined: Fri Oct 07, 2005 5:56 pm
Location: Thailand

May I have an sample for TProgress for Index

Post by dutch »

Dear All,

I've used TMeter for index progress bar and it works in 16bits but I convert to 32bits now. I don't work properly. May I have an example for Index Progress Bar?

Thanks in advance,
Dutch
User avatar
driessen
Posts: 1239
Joined: Mon Oct 10, 2005 11:26 am
Location: Genk, Belgium

Post by driessen »

Sorry, I don't have an example for an index progress bar.

But it looks strange to me that TMeter isn't working in 32-bit.

I converted a progress bar, using TMeter, from 16-bits to 32-bits too and it is working fine here.
Regards,

Michel D.
Genk (Belgium)
_____________________________________________________________________________________________
I use : FiveWin for (x)Harbour v. 21.01 - Harbour 3.2.0 (October 2020) - xHarbour Builder (January 2020) - Bcc7
User avatar
Enrico Maria Giordano
Posts: 7355
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia
Contact:

Re: May I have an sample for TProgress for Index

Post by Enrico Maria Giordano »

This is a working sample:

Code: Select all

#include "Fivewin.ch"


FUNCTION MAIN()

    LOCAL oDlg, oMtr

    LOCAL nPos

    USE TEST

    DEFINE DIALOG oDlg

    @ 1, 1 METER oMtr VAR nPos TOTAL LASTREC();
           SIZE 100, 20

    @ 3, 1 BUTTON "Start";
           ACTION STARTINDEX( oMtr )

    ACTIVATE DIALOG oDlg;
             CENTER

    CLOSE

    RETURN NIL


STATIC FUNCTION STARTINDEX( oMtr )

    INDEX ON FIELD -> last + FIELD -> first TO MTRTEST EVAL ( oMtr:Set( RECNO() ), oMtr:Refresh(), .T. )

    MSGINFO( "Done!" )

    RETURN NIL
EMG
User avatar
dutch
Posts: 1395
Joined: Fri Oct 07, 2005 5:56 pm
Location: Thailand

Post by dutch »

Dear Enrico,

Your sample is working as my 16 bits but the difference is RDD but when I use ADS, the index run fine but the Meter is not working.

I use xHarbour.com + FWH7.07 + ADS and it seem the EVAL and EVERY is working properly for ADS.

Thanks,
Dutch
User avatar
James Bott
Posts: 4654
Joined: Fri Nov 18, 2005 4:52 pm
Location: San Diego, California, USA
Contact:

Post by James Bott »

Dutch,

You can't use functions in ADS indexes. ADS is client/server and the server cannot evaluate a function that is inside the client program.

James
User avatar
dutch
Posts: 1395
Joined: Fri Oct 07, 2005 5:56 pm
Location: Thailand

Post by dutch »

Dear James,

Thank you very much for kick a mountain out of my head. I waste two days for fixing it.

Regards,
Dutch
hua
Posts: 861
Joined: Fri Oct 28, 2005 2:27 am

Post by hua »

Dutch, to show progress meter while indexing via RDDADS, use something similar to the following:

Code: Select all

FUNCtion CreateIndex( aNtxKey )

     LOCAL nCnt, lUnique

     #define ADS_ABORT    .t.
     #define ADS_CONTINUE .f.
     oNtxMeter:nTotal:=100 //LastRec()
     ADSRegCallBack({|nPercent| progress(nPercent,cNtxName)})

     FOR nCnt := 1 TO LEN( aNtxKey )

         cNtxKey  := aNtxKey[ nCnt, 1 ]
         cNtxName := aNtxKey[ nCnt, 2 ]
         cNtxFor := ""
         if len(aNtxKey[nCnt]) > 3
            cNtxFor := aNtxKey[ nCnt, 4 ]
         endif
         lUnique  := if( LEN( aNtxKey[ nCnt ] ) > 2, aNtxKey[ nCnt, 3 ], FALSE  )
         oSayText:bGet := { || "Re-building ... " + UPPER( cNtxName ) + ".NTX" }
         oSayText:Refresh()
         oNtxMeter:Set(0)
         oNtxMeter:display()

         CursorWait()

         IF lUnique
            /*
            if lExclDel
             INDEX ON &( cNtxKey ) TO ( cNtxName )  UNIQUE for !deleted() ;
                EVAL ( oNtxMeter:Set( Recno() ), SysRefresh(), .T. )
            else
            */
             INDEX ON &( cNtxKey ) TO ( cNtxName )  UNIQUE
                //EVAL ( oNtxMeter:Set( Recno() ), SysRefresh(), .T. )
                // ADS doesn't recognize eval..every
            *endif
         ELSE
            if empty(cNtxFor)
               INDEX ON &( cNtxKey ) TO ( cNtxName )
                 //EVAL ( oNtxMeter:Set( Recno() ), SysRefresh(), .T. )
            else
               INDEX ON &( cNtxKey ) TO ( cNtxName ) for &(cNtxFor)
                //EVAL ( oNtxMeter:Set( Recno() ), SysRefresh(), .T. )
            endif
         ENDIF
     NEXT
     ADSClrCallBack()
RETURN (Nil)
//-------------------------------------------------------------------------
static function progress(nPercent,CurrentNtx)
  static cNtx
  if cNtx==nil
     cNtx := ""
  endif
  if empty(cNtx)
     cNtx := currentNtx
  elseif cNtx != CurrentNtx
     cNtx := currentNtx
     oNtxMeter:Set(100)
     oNtxMeter:display()
  endif

  oNtxMeter:Set( nPercent )
  oNtxMeter:display()
return ADS_CONTINUE
User avatar
kokookao2007
Posts: 59
Joined: Thu May 17, 2007 8:27 am

Post by kokookao2007 »

Hi hua:

Great !!

It work for ADS RDD .

Best Regards

kokoo
R.F.
Posts: 840
Joined: Thu Oct 13, 2005 7:05 pm

Post by R.F. »

That's the way it works !!!!!

Why ?.... well, the explanation is very simple, ADS server does the indexing, not your program, this means that INDEX ON just send the indexing order to the server and then the server takes care of performing the operation, so your program will never know the status of the indexing progress, since you don't have a way of "asking" the ADS server the percentage of advance.

AdsClrCallBack() does a "call back" to the server, this means that the server will give your application an "status" of the currently running process.

The "call back" is only available for indexing, not for running queries (ADS does SQL queries and they are damn fast), or setting AOF() or Scopes.
Saludos
R.F.
User avatar
dutch
Posts: 1395
Joined: Fri Oct 07, 2005 5:56 pm
Location: Thailand

Post by dutch »

Thanks Hua&Rene&James,

It works well for ADS.

Regards,
Dutch
Post Reply