Page 1 of 1

advice needed on get and combobox

Posted: Mon Oct 01, 2007 8:21 am
by Richard Chidiak
Hello

I have a large table (coutry city names and zip codes) to check in my app.

Ideally this is a dbcombo feature, but unfortunately i get thrown out by xharbour for memory problems... The table has 50.000 entries. I am running a vista with 2 gb memory.

I have written a listbox (txbrowse) incremental search for it, and it works ok. My problem is calling this function meanwhile the get.

I have tried the valid clause, but this gets evaluated once the get is finished. This is what i am doing now because i have no other solution and it is not the best way.

Is there a way to type some characters in te get and have simultaneously a listbox showing values close to what you type ?

Ex : If i type P everything starting with p will appear, pa....etc

thanks for your help,

Richard

Posted: Mon Oct 01, 2007 11:35 am
by Antonio Linares
Richard,

There is an incremental search on a browse sample in FWPPC\samples\TestBrwS.prg.

The source code is basically the same for FWH :-)

Posted: Mon Oct 01, 2007 12:27 pm
by demont frank
Richard,

Some year's ago i wrote a combo class , using btnget and tsbrowse. It was on fivewin.info from patrick mast (TsCombox2.0)

The last month's it is rewritten for txbrowse. It can be used with array's (never tryed with 50000 records) , or from dbf

If you are intrested , i can send it.

Frank Demont

Posted: Mon Oct 01, 2007 1:38 pm
by driessen
Richard,

I had a similar situation in my application.

I had a get-field to input the city, then I wanted to switch to a listbox to select the right city, then I wanted to return to my original window in which the city and the zip-code are shown.

What I did is this :

Code: Select all


REDEFINE GET oGET[1] VAR cPPL ID 109 OF ParDlg PICTURE REPLICATE("X",40)
VALID (GemeenteOK("cPPNR","cPPL") .OR. ActGem("cPPNR","cPPL",ParDlg)) .AND. FocusSet(oGET[2]) UPDATE

Funtion "GemeenteOK()" checks if the zip-code(cPPNR) and the city (cPPL) belong together. If "Yes", ".T." is returned, otherwise ".F."

Function "ActGem()" shows me a listbox in a second window to select the right city and its connected zip-code. Of course you can make buttons to "Select" or "Deselect". It gives you also the opportunity to add a new city and zip-code if necessary. ".T." is always returned.

Function "FocusSet()" puts the focus on the next field. ".T." is always returned.

At the end, the VALID-clause is always ".T.", so it will never stop you of going on.

All this works very well.

Good luck.

Posted: Mon Oct 01, 2007 2:35 pm
by Richard Chidiak
Antonio

I am still using may 07 fwh, there is no testbrws in thie version .

I plan to upgrade to the next release though

Richard

Posted: Mon Oct 01, 2007 2:35 pm
by Richard Chidiak
Franck

Yes please, il qill be glad to have it

my email is richard@cbati.com

thanks in advance

Posted: Mon Oct 01, 2007 2:36 pm
by Richard Chidiak
Michel

Thanks for the suggestion, i will give it a try.

Richard

Posted: Mon Oct 01, 2007 10:05 pm
by Antonio Linares
Richard,

Here you have the source code:

Code: Select all

// FiveWin for Pocket PC - Testing browses with incremental search

#include "FWCE.ch"

REQUEST DBFCDX

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

function Main()

   local oWnd, oBrw, hBmp := ReadBitmap( CurDir() + "\go.bmp" )
   local oSay, cSearch := ""

   USE ( CurDir() + "\Customer" ) VIA "DBFCDX"
   if ! File( CurDir() + "\LAST.CDX" )
      INDEX ON Customer->Last TO ( CurDir() + "\LAST" )
   endif   
   Customer->( OrdSetFocus( "LAST" ) )
   Customer->( DbGoTop() )

   DEFINE WINDOW oWnd TITLE "IncSearch"
   
   @ 1, 1 LISTBOX oBrw ;
      FIELDS hBmp, Customer->Last, Customer->First ;
      HEADERS "", "Last", "First" ;
      SIZE 220, 167
   
   oBrw:bKeyChar = { | nKey, nFlags | Search( nKey, @cSearch ), oBrw:Refresh(),;
                                      oSay:Refresh() } 
   
   @ 14,  2 SAY "Searching:" SIZE 60, 30
   @ 14, 12 SAY oSay PROMPT cSearch SIZE 80, 30
   
   ACTIVATE WINDOW oWnd ;
      ON CLICK MsgInfo( "Click!" )
   
return nil

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

function Search( nKey, cSearch )

   if nKey = 8 
      cSearch = SubStr( cSearch, 1, Len( cSearch ) - 1 ) 
   else 
      cSearch += Upper( Chr( nKey ) ) 
   endif
    
   Customer->( DbSeek( cSearch, .t. ) ) 

return nil

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