May I have an sample for TProgress for Index

May I have an sample for TProgress for Index

Postby dutch » Sat Sep 29, 2007 6:43 pm

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
dutch
 
Posts: 1542
Joined: Fri Oct 07, 2005 5:56 pm
Location: Thailand

Postby driessen » Sat Sep 29, 2007 7:06 pm

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. 24.07 - Harbour 3.2.0 (February 2024) - xHarbour Builder (January 2020) - Bcc773
User avatar
driessen
 
Posts: 1422
Joined: Mon Oct 10, 2005 11:26 am
Location: Genk, Belgium

Re: May I have an sample for TProgress for Index

Postby Enrico Maria Giordano » Sat Sep 29, 2007 8:10 pm

This is a working sample:

Code: Select all  Expand view  RUN
#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
Enrico Maria Giordano
 
Posts: 8716
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

Postby dutch » Wed Oct 03, 2007 5:34 pm

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
dutch
 
Posts: 1542
Joined: Fri Oct 07, 2005 5:56 pm
Location: Thailand

Postby James Bott » Wed Oct 03, 2007 6:25 pm

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
James Bott
 
Posts: 4840
Joined: Fri Nov 18, 2005 4:52 pm
Location: San Diego, California, USA

Postby dutch » Wed Oct 03, 2007 6:57 pm

Dear James,

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

Regards,
Dutch
User avatar
dutch
 
Posts: 1542
Joined: Fri Oct 07, 2005 5:56 pm
Location: Thailand

Postby hua » Fri Oct 05, 2007 3:43 am

Dutch, to show progress meter while indexing via RDDADS, use something similar to the following:
Code: Select all  Expand view  RUN
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
hua
 
Posts: 1072
Joined: Fri Oct 28, 2005 2:27 am

Postby kokookao2007 » Fri Oct 05, 2007 3:37 pm

Hi hua:

Great !!

It work for ADS RDD .

Best Regards

kokoo
User avatar
kokookao2007
 
Posts: 59
Joined: Thu May 17, 2007 8:27 am

Postby R.F. » Fri Oct 05, 2007 3:50 pm

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.
R.F.
 
Posts: 840
Joined: Thu Oct 13, 2005 7:05 pm

Postby dutch » Fri Oct 05, 2007 5:24 pm

Thanks Hua&Rene&James,

It works well for ADS.

Regards,
Dutch
User avatar
dutch
 
Posts: 1542
Joined: Fri Oct 07, 2005 5:56 pm
Location: Thailand


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: Google [Bot] and 82 guests