Index with Progress

Index with Progress

Postby Silvio » Thu Aug 27, 2009 10:28 pm

Can I see a sample source code with a index with a progress ( meter)
thanks
Best Regards, Saludos

Falconi Silvio
User avatar
Silvio
 
Posts: 3107
Joined: Fri Oct 07, 2005 6:28 pm
Location: Teramo,Italy

Re: Index with Progress

Postby mmercado » Fri Aug 28, 2009 5:53 pm

Hi Silvio:
Silvio wrote:Can I see a sample source code with a index with a progress ( meter)


Here you are a working sample:
Code: Select all  Expand view
#include "FwCe.ch"

REQUEST DBFCDX

//------------------------------------------------------------------------//

Function Main()

   Local oWnd, oBtn[ 2 ], oMeter, nProg

   USE ( CurDir() + "\Customer" ) EXCLUSIVE NEW VIA "DBFCDX"

   DEFINE WINDOW oWnd TITLE "Indexing"

   @ 20, 10 BUTTON oBtn[ 1 ] PROMPT "&Index" OF oWnd SIZE 60, 20 PIXEL ;
            ACTION fIndex( oMeter )

   @ 20, 80 BUTTON oBtn[ 2 ] PROMPT "&Exit" OF oWnd SIZE 40, 20 PIXEL ;
            ACTION oWnd:End()

   @ 50,  5 PROGRESS oMeter POS nProg OF oWnd SIZE 226, 20 PIXEL

   ACTIVATE WINDOW oWnd

Return Nil

//------------------------------------------------------------------------//

Function fIndex( oMeter )

   Local nVar, nStep, nTotal
   Field Last, First

   If File( "Customer.cdx" )
      FErase( "Customer.cdx" )
   EndIf

   nTotal := RecCount()
   nStep := Max( Int( nTotal * .02 ), 1 ) // update meter every 2% of progress is faster than every record
   nVar := 0
   oMeter:SetRange( 0, nTotal )
   oMeter:SetPos( 0 )
   Index On Last + First Tag ( "LASTFIRST" ) To Customer ;
         Eval { || oMeter:SetPos( nVar += nStep ), SysRefresh(),  .T. } Every nStep

   oMeter:SetPos( nTotal )

Return Nil

Best regards.

Manuel Mercado
manuelmercado at prodigy dot net dot mx
User avatar
mmercado
 
Posts: 782
Joined: Wed Dec 19, 2007 7:50 am
Location: Salamanca, Gto., México

Re: Index with Progress

Postby Silvio » Fri Aug 28, 2009 6:02 pm

thanks manuel!
Best Regards, Saludos

Falconi Silvio
User avatar
Silvio
 
Posts: 3107
Joined: Fri Oct 07, 2005 6:28 pm
Location: Teramo,Italy

Re: Index with Progress

Postby Silvio » Fri Aug 28, 2009 8:00 pm

Dear Manuel,

I compiled it

it run but not create cdx file

why ?
Best Regards, Saludos

Falconi Silvio
User avatar
Silvio
 
Posts: 3107
Joined: Fri Oct 07, 2005 6:28 pm
Location: Teramo,Italy

Re: Index with Progress

Postby mmercado » Sat Aug 29, 2009 12:23 am

Hi Silvio:
Silvio wrote:it run but not create cdx file

Please try this way and let me know the result (for me it's working):
Code: Select all  Expand view
#include "FwCe.ch"

REQUEST DBFCDX

//------------------------------------------------------------------------//

Function Main()

   Local oWnd, oBtn[ 2 ], oMeter, nProg

   DEFINE WINDOW oWnd TITLE "Indexing"

   @ 20, 10 BUTTON oBtn[ 1 ] PROMPT "&Index" OF oWnd SIZE 60, 20 PIXEL ;
            ACTION fIndex( oMeter )

   @ 20, 80 BUTTON oBtn[ 2 ] PROMPT "&Exit" OF oWnd SIZE 40, 20 PIXEL ;
            ACTION oWnd:End()

   @ 50,  5 PROGRESS oMeter POS nProg OF oWnd SIZE 226, 20 PIXEL

   ACTIVATE WINDOW oWnd

Return Nil

//------------------------------------------------------------------------//

Function fIndex( oMeter )

   Local nVar, nStep, nTotal
   Field Last, First

   If File( CurDir() + "\Customer.cdx" )
      FErase( CurDir() + "\Customer.cdx" )
   EndIf

   USE ( CurDir() + "\Customer" ) EXCLUSIVE NEW VIA "DBFCDX"

   nTotal := RecCount()
   nStep := Max( Int( nTotal * .02 ), 1 ) // update meter every 2% of progress is faster than every record
   nVar := 0
   oMeter:SetRange( 0, nTotal )
   oMeter:SetPos( 0 )
   Index On Last + First Tag ( "LASTFIRST" ) ;
         Eval { || oMeter:SetPos( nVar += nStep ), SysRefresh(),  .T. } Every nStep

   oMeter:SetPos( nTotal )

Return Nil

Best regards.

Manuel Mercado
manuelmercado at prodigy dot net dot mx
User avatar
mmercado
 
Posts: 782
Joined: Wed Dec 19, 2007 7:50 am
Location: Salamanca, Gto., México

Re: Index with Progress

Postby Silvio » Sat Aug 29, 2009 3:32 pm

run but not create the index


I change this line

Index On Last + First Tag ( "LASTFIRST" ) To Customer ;
Eval { || oMeter:SetPos( nVar += nStep ), SysRefresh(), .T. } Every nStep

for

Index On Last + First Tag LASTFIRST To Customer ;
Eval { || oMeter:SetPos( nVar += nStep ), SysRefresh(), .T. } Every nStep



and it run ok and create cdx


it is perhaps an bug of my version of harbour_ce ?

I found there is the error on tag when I create index cdx with tag

for sample theseline are not runned

if ! File( CurDir() + "\data\CLIENTI.CDX" )
INDEX ON CLIENTI->NUMCLI TAG CLIXCVE TO ( CurDir() + "\data\CLIENTI" )
INDEX ON CLIENTI->RAZSOC TAG CLIXDES TO ( CurDir() + "\data\CLIENTI" )
INDEX ON DTOS(CLIENTI->ULTVEN) TAG CLIXFEC TO ( CurDir() + "\data\CLIENTI" )
INDEX ON CLIENTI->SALACT TAG CLIXSAL TO ( CurDir() + "\data\CLIENTI" )
INDEX ON CLIENTI->VENNET TAG CLIXVEN TO ( CurDir() + "\data\CLIENTI" )
INDEX ON CLIENTI->RUTA+RAZSOC TAG CLIXRUT TO ( CurDir() + "\data\CLIENTI" )
endif


the archive clienti is founded but it not create cdx if there is a tag

I tryed to talk with antonio and know to him my problem but I saw the problem not is a universal problem and non resolve my problems


I know well How create index with progress on fwh but if I asked to forum this problem perhaps the problem is another ......
Best Regards, Saludos

Falconi Silvio
User avatar
Silvio
 
Posts: 3107
Joined: Fri Oct 07, 2005 6:28 pm
Location: Teramo,Italy

Re: Index with Progress

Postby Silvio » Sat Aug 29, 2009 4:04 pm

Manuel ,
Here there is my sample test with ten progress control on the wnd
the problem is :

1. the windows is not full open
2. I cannot erase buttonbar on botton ( see the picture)


Image


the code:

Code: Select all  Expand view


#include "FwCe.ch"

REQUEST DBFCDX



/*

SAMPLE TEST FOR INDEX   ARCHIVES WITH PROGRESS CONTROL  OF AN APPLICATION

ON TEST THERE ARE 5  PROGRESS CONTROL

*/




static cPath

//------------------------------------------------------------------------//

Function Main()

   Local oWnd, oBtn[ 2 ], oMeter, nProg

   Local oMeter1 , oMeter2 , oMeter3 , oMeter4 , oMeter5
   Local  oMeter6 , oMeter7 , oMeter8,  oMeter9 , oMeter10

   Local lPack :=.F.

   DEFINE WINDOW oWnd TITLE "Indexing"

   HideKeyboard()



   @ 10,  5 PROGRESS oMeter1 POS nProg OF oWnd SIZE 226, 20 PIXEL

   @ 35,  5 PROGRESS oMeter2 POS nProg OF oWnd SIZE 226, 20 PIXEL

   @ 60,  5 PROGRESS oMeter3 POS nProg OF oWnd SIZE 226, 20 PIXEL

   @ 85,  5 PROGRESS oMeter4 POS nProg OF oWnd SIZE 226, 20 PIXEL

   @ 110,  5 PROGRESS oMeter5 POS nProg OF oWnd SIZE 226, 20 PIXEL

   @ 135,  5 PROGRESS oMeter6 POS nProg OF oWnd SIZE 226, 20 PIXEL

   @ 160,  5 PROGRESS oMeter7 POS nProg OF oWnd SIZE 226, 20 PIXEL

   @ 185,  5 PROGRESS oMeter8 POS nProg OF oWnd SIZE 226, 20 PIXEL

   @ 210,  5 PROGRESS oMeter9 POS nProg OF oWnd SIZE 226, 20 PIXEL

   @ 235,  5 PROGRESS oMeter10 POS nProg OF oWnd SIZE 226, 20 PIXEL


   @ 250, 15 CHECKBOX lPack PROMPT "&Pack"     OF oWnd  SIZE 60, 15 PIXEL

   @ 250, 95 BUTTON oBtn[ 1 ] PROMPT "&Index" OF oWnd SIZE 60, 20 PIXEL ;
            ACTION fIndex( lPack,oMeter1 , oMeter2 , oMeter3 , oMeter4 , oMeter5, oMeter6 , oMeter7 , oMeter8, oMeter9 , oMeter10, oWnd )

   @ 250, 180 BUTTON oBtn[ 2 ] PROMPT "&Exit" OF oWnd SIZE 40, 20 PIXEL ;
            ACTION oWnd:End()


   ACTIVATE WINDOW oWnd;
   ON INIT DlgFullScreen( oWnd:hWnd )

Return Nil

//------------------------------------------------------------------------//

Function fIndex(  lPack,oMeter1 , oMeter2 , oMeter3 , oMeter4 , oMeter5, oMeter6 , oMeter7 , oMeter8, oMeter9 , oMeter10, oWnd)

   Local nVar, nStep, nTotal




/// ---- here I take the path on the control archive

   IF NetUse(  CurDir() +"\control",.F.)
         cPath:=Alltrim(Control->Data)+"\"
         dbCloseArea()
      ENDIF




       // clienti

        IF NetUse(  CurDir() +cPath+ "
CLIENTI",.F.)
              If File( CurDir() +cPath+ "
clienti.cdx" )
                  FErase( CurDir() +cPath+ "
clienti.cdx" )
              EndIf
              IF lPack = .T.
                 PACK
              ENDIF
              nTotal := RecCount()
              nStep := Max( Int( nTotal * .02 ), 1 )
               nVar := 0
              oMeter1:SetRange( 0, nTotal )
              oMeter1:SetPos( 0 )
              @ 150, 5 say "
Sto indicizzando l'archivio dei clienti"  OF oWnd SIZE 220, 20 PIXEL
             *  Index On Field->Last + Field->First Tag LASTFIRST To Customer ;
             *        Eval { || oMeter1:SetPos( nVar += nStep ), SysRefresh(),  .T. } Every nStep


      Index On Field->Numcli  Tag CLIXCVE  TO ( CurDir() +cPath+ "CLIENTI" )
      oMeter1:SetPos(15)

      Index On Field->RAZSOC  Tag CLIXDES  TO ( CurDir() +cPath+ "CLIENTI" )
       oMeter1:SetPos(30)

      Index On DTOS(Field->ULTVEN) TAG  CLIXFEC  TO ( CurDir() +cPath+ "CLIENTI" )
      oMeter1:SetPos(45)

      Index ON Field->SALACT       TAG  CLIXSAL  TO ( CurDir() +cPath+ "CLIENTI" )
      oMeter1:SetPos(60)

      INDEX ON Field->VENNET       TAG  CLIXVEN  TO ( CurDir() +cPath+ "CLIENTI" )
      oMeter1:SetPos(75)

      INDEX ON Field->RUTA+ Field->RAZSOC  TAG  CLIXRUT  TO ( CurDir() +cPath+ "CLIENTI" )
      oMeter1:SetPos(100)

  * oMeter1:SetPos( nTotal )

   dbCloseArea()
 ENDIF





















   Return Nil





 // functions for the sample test



FUNCTION NetUse( cDbf, lShared )

   LOCAL cAlias := cFileName( cDbf )

   If cDbf = NIL .OR. !File( cDbf + ".DBF" )
      MsgStop( "NOME ERRATO" + CRLF + "o" + CRLF + ;
             "NON POSSO TROVARE LA BASE DEI DATI." + CRLF + cDbf + ".DBF", "ERROR" )
      RETURN( .F. )
   ENDIF

   IIf( lShared = NIL, lShared := .F., lShared )

   IF lShared = .T.
      USE (cDbf) ALIAS (cAlias := GetNewAlias( cAlias )) VIA "DBFCDX" SHARED NEW
   ELSE
      USE (cDbf) ALIAS (cAlias) VIA "DBFCDX" EXCLUSIVE NEW
   ENDIF

   IF !NetErr()
      RETURN( .T. )
   ENDIF


   MsgStop( "IMPOSIBLE APRIRE IL FILE " + cAlias + CRLF + ;
            OemToAnsi( "bloccato da un altro utente." ), ;
            "ERRORE" )

RETURN( .F. )

FUNCTION GetNewAlias( cAlias )
   STATIC n := 0
RETURN cAlias + StrZero( ++n, 4 )



 #pragma BEGINDUMP

#include <hbapi.h>
#include <windows.h>
#include <aygshell.h>


HB_FUNC( DLGFULLSCREEN )
{
SHINITDLGINFO shidi;

memset( &shidi, 0, sizeof( SHINITDLGINFO ) );

shidi.dwMask = SHIDIM_FLAGS;
shidi.hDlg = ( HWND ) hb_parnl( 1 );
shidi.dwFlags = SHIDIF_SIZEDLGFULLSCREEN;

SHInitDialog( &shidi );
}

  #pragma ENDDUMP







Best Regards, Saludos

Falconi Silvio
User avatar
Silvio
 
Posts: 3107
Joined: Fri Oct 07, 2005 6:28 pm
Location: Teramo,Italy


Return to FiveWin for Pocket PC

Who is online

Users browsing this forum: No registered users and 6 guests