xBrowse incremental search

xBrowse incremental search

Postby Detlef Hoefner » Fri May 29, 2009 9:58 am

Hi all,

i have customers xBrowse with dbfntx on upper( name ).
I would like to search by typing a customer name without using the shift key.
Unfortunatelly it doesn't seek.
here my code:

Code: Select all  Expand view

   oBrwLf := XbrowseNew( oDlg, nil, nil, nil, nil,,,,;
      { || oSysTitle:SetText( " POs at " + lf->name1 ) },,,,, 0, CLR_4,, .f., "lf",, .f.,, .t., 80, .t., .f. ,,,,, .f., .f., .f., .t. )
   
      oBrwLf:AddColumn( "LfNr.", { || lf->lfnr },,,, "LEFT", 45, .F., .F.,,,,,, .F., "lfnr",,,, .F.,,, )
      oBrwLf:AddColumn( "Name" , { || lf->name1 + CRLF + lf->name2 },,,, "LEFT", 200, .F., .F.,,,,,, .F., "lfname",,,, .F.,,, )
     
   REDEFINE SAY oBrwLf:oSeek PROMPT oBrwLf:cSeek ID 81  OF oDlg

   WITH OBJECT oBrwLf
        :bSeek      := { |c| lf->( DbSeek( upper( c ), .t. ) ), !lf->( eof() ) }
        :nDataLines := 2
   END
 

If i type a letter the browse doesn't move and the letter is not diplayed in the seek say.
But when i use the shift key to type capital letters, the browse moves correctly and the letter is displayed in the seek say.

Could anybody give me a tip what' s wrong with that?


Thanks and regards,
Detlef
User avatar
Detlef Hoefner
 
Posts: 312
Joined: Sat Oct 08, 2005 9:12 am
Location: Germany

Re: xBrowse incremental search

Postby ukoenig » Fri May 29, 2009 11:51 am

Hello Detlef,

I use this some years already and it works fine for me ( maybe a bit old fashion ).
If the browser has the focus, the input is displayed in the say and starts the incremental-seek.
Inside the function, You have absolute control what You want to do, the user presses a special key.

Code: Select all  Expand view


// Input-Control
// -----------------
REDEFINE SAY oSEEK VAR  cSEEK  ID 100 OF oDlg COLORS CLR_WHITE, CLR_BLUE UPDATE

oLbx:bKeyChar   := {| nKey | oldpos := ORDKEYNO(), RE_SUCH(nKey,oSEEK,oLbx), ;
   oLbx:Refresh(), oLbx:oVScroll:SetPos(ORDKEYNO()) }

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

FUNCTION RE_SUCH(nKey,oSEEK,oLbx)  

IF nKey > 0
    IF nKey <> 13
        xlen := len(cSEEK)
        IF nKey = 27
            cSEEK := ""
        ENDIF
        IF nKey = 8 .and. cSEEK <> "" // right Mouse-click emptys the seek-field (Init)
            cSEEK := substr(cSEEK,1,xlen-1)
            IF old_Index = 4  // a special Index is used
                //  DESCEND(str(jahrgang) + rechng_nr + Upper(archiv_nr))" } )  // 34
                DBSEEK(DESCEND(cSEEK))
            ELSE
                DBSEEK(cSEEK)
            ENDIF
            IF !Found()
                MsgAlert("Not Found !", "Attention")
                cSEEK := ""
                DBGOTOP()
            ENDIF
        ELSE
            cSEEK := cSEEK+ AnsiToOem(CHR(nKey))
            IF old_Index = 4
                //  DESCEND(str(jahrgang) + rechng_nr + Upper(archiv_nr))" } )  // 34
                DBSEEK(DESCEND(cSEEK))
            ELSE
                DBSEEK(cSEEK)
            ENDIF
            IF !Found()
                MsgAlert("Not Found !", "Attention")
                cSEEK := ""
                DBGOTOP()
            ENDIF
        ENDIF
        IF cSEEK = ""
            DBGOTO(oldpos)
        ENDIF
        oLbx:Refresh()
    ENDIF
ENDIFf

RETURN( NIL )
 


Best Regards
Uwe :lol:
Since 1995 ( the first release of FW 1.9 )
i work with FW.
If you have any questions about special functions, maybe i can help.
User avatar
ukoenig
 
Posts: 4043
Joined: Wed Dec 19, 2007 6:40 pm
Location: Germany

Re: xBrowse incremental search

Postby Detlef Hoefner » Fri May 29, 2009 12:11 pm

Uwe,

thanks for your suggest.
A code like yours would be my workaround.

But my intention was to avoid such additional coding for we have a bSeek block of the xBrowse class.
Unfortunately it doesn't seem to work as expected. :(

Thanks and regards,
Detlef
User avatar
Detlef Hoefner
 
Posts: 312
Joined: Sat Oct 08, 2005 9:12 am
Location: Germany

Re: xBrowse incremental search

Postby ukoenig » Fri May 29, 2009 12:45 pm

Hello Detlef,

maybe a solution with a codeblock is possible, lets wait.
Just something I remember to include inside the function.
A help during the seek :

The SAY ( seeking a name ) : Hoefn?

If the user presses a ? You can include :

IF nKey = 63
Msgalert( "This is a message.....", "Attention" )
// delete the ? after closing the message
// ---------------------------------------------
cSEEK := substr(cSEEK,1,xlen-1)
ENDIF

Or allow only 0 - 1 and A - X ( nKey = 48 - 57 and 65 - 90 )

I see, that You are using NTX with UPPER
If You want to change from NTX to CDX ( maybe planed for the future ),
UPPER on Index-key doesn't work because of < ÖÜÄß > You have to change to LOWER.

Best Regards
Uwe :lol:
Since 1995 ( the first release of FW 1.9 )
i work with FW.
If you have any questions about special functions, maybe i can help.
User avatar
ukoenig
 
Posts: 4043
Joined: Wed Dec 19, 2007 6:40 pm
Location: Germany

Re: xBrowse incremental search

Postby nageswaragunupudi » Fri May 29, 2009 2:52 pm

Simple oBrw:bSeek := { |c| (oBrw:cAlias)->( DbSeek( Upper( c ) ) ) } should work and works for me ( for character columns if index is on Upper(...) and browse has focus )

Please make sure the Browse has focus ( normally better we set focus on int clause ) and the proper index is selected. Please note SoftSeek need not be used.

One friendly advice:
Please read the comments included in the method AddColumn( ... )
// This method is intended only to support command syntax
// and this method should not be called directly in the
// application program


This method is mean to support the command syntax of 'ADD TO oBrw'. If we insist on using OOPS syntax, but not the command syntax, we better go by the original way of oCol := oBrw:AddCol() and then set each data individually. From the above notes there is no guarantee that in future versions the method will retain compatibility with the present version.
Regards

G. N. Rao.
Hyderabad, India
User avatar
nageswaragunupudi
 
Posts: 10625
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: xBrowse incremental search

Postby Detlef Hoefner » Fri May 29, 2009 3:13 pm

nageswaragunupudi wrote:Simple oBrw:bSeek := { |c| (oBrw:cAlias)->( DbSeek( Upper( c ) ) ) } should work and works for me ( for character columns if index is on Upper(...) and browse has focus )

Please make sure the Browse has focus ( normally better we set focus on int clause ) and the proper index is selected. Please note SoftSeek need not be used.

One friendly advice:
Please read the comments included in the method AddColumn( ... )
// This method is intended only to support command syntax
// and this method should not be called directly in the
// application program

This method is mean to support the command syntax of 'ADD TO oBrw'. If we insist on using OOPS syntax, but not the command syntax, we better go by the original way of oCol := oBrw:AddCol() and then set each data individually. From the above notes there is no guarantee that in future versions the method will retain compatibility with the present version.


Rao,

many thanks for your advices.
As i already wrote, the index is on Upper( field->name ) and the Browse does seek it and move correctly.
But only if i type capital letters using the shift key.

When i read your fiendly advice i got an idea.
I didn't use the xbase syntax because the program uses lots of Manuels TsBrowse objects. So i had to include "tsbrowse.ch" which doesn't correctly translate the xBrowse commands.

May be my error with bSeek could result from using xBrowse and TsBrowse libs in the same program?

I'll try to find out this.

Thanks and regards, Rao,
Detlef
User avatar
Detlef Hoefner
 
Posts: 312
Joined: Sat Oct 08, 2005 9:12 am
Location: Germany

Re: xBrowse incremental search

Postby nageswaragunupudi » Fri May 29, 2009 3:52 pm

>
May be my error with bSeek could result from using xBrowse and TsBrowse libs in the same program?
>
I don't think so. XBrowse will use its own methods for bSeek
In any case, it may be a good idea to keep sbrowse and xbrowses in different program modules. Not desirable to have both browses in the same program file. Not even TCBrowse and TXBrowse.

I wish I can reproduce your problem at my end. When I am trying it is working
Regards

G. N. Rao.
Hyderabad, India
User avatar
nageswaragunupudi
 
Posts: 10625
Joined: Sun Nov 19, 2006 5:22 am
Location: India


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: Google [Bot] and 101 guests