Updating SAY When Indexing

Post Reply
Bill Simmeth
Posts: 42
Joined: Wed Oct 26, 2005 1:20 pm
Location: Marshall, Virginia, USA
Contact:

Updating SAY When Indexing

Post by Bill Simmeth »

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!

Code: Select all | Expand

#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
User avatar
Antonio Linares
Site Admin
Posts: 42519
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Has thanked: 31 times
Been thanked: 75 times
Contact:

Post by Antonio Linares »

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
Bill Simmeth
Posts: 42
Joined: Wed Oct 26, 2005 1:20 pm
Location: Marshall, Virginia, USA
Contact:

Post by Bill Simmeth »

Ah, very good. This solves it. Thank you for this tip!
Bill Simmeth
Merchant Software Corp
Marshall, Virginia USA
Post Reply