FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Pocket PC Updating SAY When Indexing
Posts: 42
Joined: Wed Oct 26, 2005 01:20 PM
Updating SAY When Indexing
Posted: Thu Aug 03, 2006 06:35 PM
Hi,

Perhaps someone can see a solution to my problem. I have put together a file maintenance section to reindex files on the PocketPC if necessary. I would like to give the user feedback with a status SAY and a progress bar. The progress bar works flawlessly, but updates to the SAY are blocked until the indexing is complete. The sample below (sorry for the length) works with the customer.dbf in the \SAMPLES directory.

Thanks in advance!

#include "FWCE.ch"

REQUEST DBFCDX

******************************************************************************
FUNCTION Main()
******************************************************************************
LOCAL oWnd, oBar, oSay

   DEFINE WINDOW oWnd TITLE "Index"

   @ 40, 5 BUTTON "Index" OF oWnd SIZE 80, 25 PIXEL ;
           ACTION ( oSay:setText( "Now indexing..." ), DoIndex( oBar, oSay ) )

   @ 160, 5 SAY oSay PROMPT "File Progress..." OF oWnd SIZE 230, 20 PIXEL

   @ 180, 5 PROGRESS oBar OF oWnd SIZE 230, 15 PIXEL

   oBar:SetRange( 0, 100 )
   oBar:nPosition := 0

   ACTIVATE WINDOW oWnd

RETURN NIL

******************************************************************************
Procedure DoIndex( oBar, oSay )
******************************************************************************

   Select 0
   USE ( CurDir() + "\customer" ) VIA "DBFCDX" Exclusive

   oSay:setText( "Indexing to tag LAST..." )
   ordCreate( ( CurDir() + "\customer" ), "LAST", "last", {|| Ndxbar(oBar,1), last } )

   Sleep( 2000 )
   oBar:nPosition := 0
   Sleep( 2000 )

   oSay:setText( "Indexing to tag FIRST..." )
   ordCreate( ( CurDir() + "\customer" ), "FIRST", "first", {|| Ndxbar(oBar,1), first } )

   Sleep( 2000 )
   oBar:nPosition := 0
   Sleep( 2000 )

   oSay:setText( "Indexing to tag CITY..." )
   ordCreate( ( CurDir() + "\customer" ), "CITY", "city", {|| Ndxbar(oBar,1), city } )

   CLOSE ALL

   Sleep( 2000 )

   MsgInfo( "Done!" )

Return

******************************************************************************
FUNCTION Ndxbar(oBar,nEvery)
******************************************************************************
LOCAL nLastrec

STATIC nCounter := 0

DEFAULT nEvery := 10

   IF ++nCounter >= nEvery
      nCounter := 0
      nLastrec := lastrec()
      IF nLastrec > 0
         oBar:nPosition := ((recno()/nLastrec)*100)
      ENDIF
   ENDIF

RETURN nil

#pragma BEGINDUMP

#include "windows.h"
#include "hbapi.h"

HB_FUNC( SLEEP )
{
    Sleep( hb_parnl( 1 ) );
}

#pragma ENDDUMP
Bill Simmeth

Merchant Software Corp

Marshall, Virginia USA
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Updating SAY When Indexing
Posted: Thu Aug 03, 2006 08:14 PM

Bill,

Place a call to SysRefresh() from Ndxbar(). You may fine tune it to not call it everytime as it is time consuming.

regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 42
Joined: Wed Oct 26, 2005 01:20 PM
Updating SAY When Indexing
Posted: Thu Aug 03, 2006 08:19 PM

Ah, very good. This solves it. Thank you for this tip!

Bill Simmeth

Merchant Software Corp

Marshall, Virginia USA

Continue the discussion