Updating SAY When Indexing

Updating SAY When Indexing

Postby Bill Simmeth » Thu Aug 03, 2006 6: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!

Code: Select all  Expand view
#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
Bill Simmeth
 
Posts: 42
Joined: Wed Oct 26, 2005 1:20 pm
Location: Marshall, Virginia, USA

Postby Antonio Linares » Thu Aug 03, 2006 8: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
User avatar
Antonio Linares
Site Admin
 
Posts: 41937
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Postby Bill Simmeth » Thu Aug 03, 2006 8:19 pm

Ah, very good. This solves it. Thank you for this tip!
Bill Simmeth
Merchant Software Corp
Marshall, Virginia USA
Bill Simmeth
 
Posts: 42
Joined: Wed Oct 26, 2005 1:20 pm
Location: Marshall, Virginia, USA


Return to FiveWin for Pocket PC

Who is online

Users browsing this forum: No registered users and 32 guests

cron