Multiple search on Xbrowse ( to Mr Nages)

Multiple search on Xbrowse ( to Mr Nages)

Postby Silvio.Falconi » Thu May 09, 2013 2:43 pm

I wish search with xbrowse with some field ( incrfilter) But I not Know How make it

I Know and I have a test how make it with one get or a say but there is not a test sample with more gets


I wish the final user can insert the first, Last, City and state to found a customer into xbrowse

I made this sample :

Code: Select all  Expand view

#include 'fivewin.ch'
#include 'ord.ch'
#include 'xbrowse.ch'
#include 'hbcompat.ch'

REQUEST DBFCDX

static cSeek   := ''
static oSeek

function Main()

   local oDlg, oBrw,oGrp1
   local aGet[4]

   local cFirst:=space(20)
   local cLast :=space(20)
   local cState:=space(2)
   local cCity:=space(30)

    SetGetColorFocus()
   RDDSETDEFAULT( "DBFCDX" )
   USE CUSTOMER
   INDEX ON FIRST  TAG FIRST    TO TMFIRST  MEMORY
   INDEX ON LAST   TAG LAST     TO TMPLAST  MEMORY
   INDEX ON CITY   TAG CITY     TO TMPCITY  MEMORY
   INDEX ON STATE  TAG STATE    TO TMPSTATE MEMORY
   SET ORDER TO TAG FIRST
   GO TOP




     Define DIALOG oDlg TITLE "Searching Customers - " ;
         FROM 452, 774 to 870, 1303 PIXEL COLOR 0, 14215660 //FONT  oFont


       @    1,    4 GROUP oGrp1 TO  65, 255 LABEL "Search" PIXEL;
              OF oDlg COLOR 0, 14215660



       @   24,  11 SAY "&First:"     SIZE  55,   7 PIXEL  OF  oDlg  COLOR 0, 14215660
       @   38,  11 SAY "&Last :"     SIZE  55,   7 PIXEL  OF  oDlg  COLOR 0, 14215660
       @   54,  11 SAY "City:"       SIZE  25,   7 PIXEL  OF  oDlg  COLOR 0, 14215660
       @   54,  204 SAY "State:"     SIZE  25,   7 PIXEL  OF  oDlg  COLOR 0, 14215660

       @  22,  45  GET aGet[1] VAR cFirst  SIZE  130,  10  PIXEL OF oDlg
       @  36,  45  GET aGet[2] VAR cLast  SIZE  130,  10  PIXEL OF oDlg
       @  52,  45  GET aGet[3] VAR cState SIZE  130,  10  PIXEL OF oDlg
       @  52,  235 GET aGet[4] VAR cCity  SIZE   14,  10  PIXEL OF oDlg

           *  cSeek := cFirst

      @ 80,10 XBROWSE oBrw SIZE -10,-10 PIXEL OF oDlg ;
      AUTOCOLS ALIAS "CUSTOMER" CELL LINES NOBORDER

    *  oSeek:bKeyDown := { | nKey | KeyChar( oBrw, nKey ) }
            aGet[1]:bKeyDown := { | nKey | KeyChar( oBrw, nKey ) }
            aGet[2]:bKeyDown := { | nKey | KeyChar( oBrw, nKey ) }

   oBrw:bSeek  := nil

   oBrw:bKeyChar  := { |nKey| KeyChar( oBrw, nKey ) }



                  oBrw:CreateFromCode()





     ACTIVATE DIALOG oDlg  CENTERED

     RETURN NIL






static function KeyChar( oBrw, nKey )

   If nKey == VK_BACK .and. ! Empty( cSeek )
      ( oBrw:cAlias )->( IncrFilter( oBrw, Left( cSeek, Len( cSeek ) -1 ) ) )
      return 0
   elseIf nKey > 31
      ( oBrw:cAlias )->( IncrFilter( oBrw, cSeek + Chr( nKey ) ) )
      return 0
   Endif

return nil

static function IncrFilter( oBrw, cPattern )

   local cFilter, lFound := .f.
   local nRecNo, cSaveFilt, lStay

   if ValType( cPattern ) == 'C'
      if Empty( cPattern )
         cSeek       := ""
         * oSeek:SetText( cSeek )

         oSeek:cText( cSeek )
         oSeek:REFRESH()
         SET FILTER TO !DELETED()
         GO TOP
         oBrw:Refresh()
         lFound      := .t.
      else
         cFilter     := 'WildMatch( "*' + Upper(cPattern) + '*", UPPER( FIRST )) .AND. !DELETED()'
         cSaveFilt   := DBFILTER()
         nRecNo      := RECNO()
         lStay       := &cFilter
         SET FILTER TO &cFilter
         GO TOP
         if OrdKeyCount() == 0
            SET FILTER TO &cSaveFilt
            GO TOP
            DBGOTO( nRecNo )
         else
            cSeek    := cPattern
            oSeek:cText( cSeek )
         oSeek:REFRESH()

            if lStay
               DBGOTO( nRecNo )
               oBrw:Refresh()
            else
               oBrw:Refresh( .t. )
            endif
            lFound   := .t.
         endif
      endif
   endif

return lFound






 
Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)
I use : FiveWin for Harbour November 2023 - January 2024 - Harbour 3.2.0dev (harbour_bcc770_32_20240309) - Bcc7.70 - xMate ver. 1.15.3 - PellesC - mail: silvio[dot]falconi[at]gmail[dot]com
User avatar
Silvio.Falconi
 
Posts: 7056
Joined: Thu Oct 18, 2012 7:17 pm

Re: Multiple search on Xbrowse ( to Mr Nages)

Postby nageswaragunupudi » Thu May 09, 2013 3:11 pm

If you are using Gets then you should set your own filter in the valid clause.
Regards

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

Re: Multiple search on Xbrowse ( to Mr Nages)

Postby Silvio.Falconi » Thu May 09, 2013 3:55 pm

Mr Nages ...

I found a solution but perhaps.... it is a bug


Image







@ 24, 11 SAY "&First:" SIZE 55, 7 PIXEL OF oDlg COLOR 0, 14215660
@ 38, 11 SAY "&Last :" SIZE 55, 7 PIXEL OF oDlg COLOR 0, 14215660
@ 54, 11 SAY "City:" SIZE 25, 7 PIXEL OF oDlg COLOR 0, 14215660
@ 54, 204 SAY "State:" SIZE 25, 7 PIXEL OF oDlg COLOR 0, 14215660

@ 22, 45 GET aGet[1] VAR cFirst SIZE 130, 10 PIXEL OF oDlg ON CHANGE ( oBrw:cSeek:=AllTrim( cFirst ) )
@ 36, 45 GET aGet[2] VAR cLast SIZE 130, 10 PIXEL OF oDlg ON CHANGE ( oBrw:cSeek:=AllTrim( cLast ) )
@ 52, 45 GET aGet[3] VAR cState SIZE 130, 10 PIXEL OF oDlg ON CHANGE ( oBrw:cSeek:=AllTrim( cState ) )
@ 52, 235 GET aGet[4] VAR cCity SIZE 14, 10 PIXEL OF oDlg ON CHANGE ( oBrw:cSeek:=AllTrim( cCity ) )


@ 10,10 GET oSeek VAR cSeek SIZE 1,1 PIXEL OF oDlg COLOR CLR_BLACK,CLR_YELLOW


oSeek:bKeyDown := { | nKey | KeyChar( oBrw, nKey ) }

aGet[1]:bKeyDown := { | nKey | KeyChar( oBrw, nKey ) }
aGet[2]:bKeyDown := { | nKey | KeyChar( oBrw, nKey ) }
aGet[3]:bKeyDown := { | nKey | KeyChar( oBrw, nKey ) }
aGet[4]:bKeyDown := { | nKey | KeyChar( oBrw, nKey ) }


oBrw:bSeek := nil

oBrw:bKeyChar := { |nKey| KeyChar( oBrw, nKey ) }



opps I saw now it run only for first field
Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)
I use : FiveWin for Harbour November 2023 - January 2024 - Harbour 3.2.0dev (harbour_bcc770_32_20240309) - Bcc7.70 - xMate ver. 1.15.3 - PellesC - mail: silvio[dot]falconi[at]gmail[dot]com
User avatar
Silvio.Falconi
 
Posts: 7056
Joined: Thu Oct 18, 2012 7:17 pm

Re: Multiple search on Xbrowse ( to Mr Nages)

Postby Silvio.Falconi » Thu May 09, 2013 4:53 pm

ok Now Understood How make it :

@ 24, 11 SAY "&First:" SIZE 55, 7 PIXEL OF oDlg COLOR 0, 14215660
@ 38, 11 SAY "&Last :" SIZE 55, 7 PIXEL OF oDlg COLOR 0, 14215660
@ 54, 11 SAY "City:" SIZE 25, 7 PIXEL OF oDlg COLOR 0, 14215660
@ 54, 204 SAY "State:" SIZE 25, 7 PIXEL OF oDlg COLOR 0, 14215660

@ 22, 45 GET aGet[1] VAR cFirst SIZE 130, 10 PIXEL OF oDlg ON CHANGE (oBrw:cSeek:=AllTrim( cFirst ) )
@ 36, 45 GET aGet[2] VAR cLast SIZE 130, 10 PIXEL OF oDlg ON CHANGE (oBrw:cSeek:=AllTrim( cLast ) )
@ 52, 45 GET aGet[3] VAR cCity SIZE 130, 10 PIXEL OF oDlg ON CHANGE (oBrw:cSeek:=AllTrim( cCity) )
@ 52, 235 GET aGet[4] VAR cState SIZE 14, 10 PIXEL OF oDlg ON CHANGE (oBrw:cSeek:=AllTrim( cState ) )



@ 10,10 GET oSeek VAR cSeek SIZE 1,1 PIXEL OF oDlg COLOR CLR_BLACK,CLR_YELLOW


oSeek:bKeyDown := { | nKey | KeyChar( oBrw, nKey ) }

aGet[1]:bKeyDown := { | nKey | KeyChar( oBrw, nKey,1) }
aGet[2]:bKeyDown := { | nKey | KeyChar( oBrw, nKey,2) }
aGet[3]:bKeyDown := { | nKey | KeyChar( oBrw, nKey,3) }
aGet[4]:bKeyDown := { | nKey | KeyChar( oBrw, nKey,4) }


and then I change the functions KeyChar and IncrFilter but I'm sure you Mr Nage found a good solution

Code: Select all  Expand view


static function KeyChar( oBrw, nKey,n)

   If nKey == VK_BACK .and. ! Empty( cSeek )
      ( oBrw:cAlias )->( IncrFilter( oBrw, Left( cSeek, Len( cSeek ) -1 ),n,"CUST") )
      return 0
   elseIf nKey > 31
      ( oBrw:cAlias )->( IncrFilter( oBrw, cSeek + Chr( nKey ),n,"CUST") )
      return 0
   Endif

return nil

static function IncrFilter( oBrw, cPattern,n,cdbf)

   local cFilter, lFound := .f.
   local nRecNo, cSaveFilt, lStay

        (cdbf)->(OrdSetFocus(n))


   if ValType( cPattern ) == 'C'
      if Empty( cPattern )
         cSeek       := ""
         * oSeek:SetText( cSeek )

         oSeek:cText( cSeek )
         oSeek:REFRESH()
         SET FILTER TO !DELETED()
         GO TOP
         oBrw:Refresh()
         lFound      := .t.
      else


          if  n = 1
                cFilter     := 'WildMatch( "*' + Upper(cPattern) + '*", UPPER( FIRST )) .AND. !DELETED()'
             elseif  n = 2
                cFilter     := 'WildMatch( "*' + Upper(cPattern) + '*", UPPER( LAST )) .AND. !DELETED()'
             elseif  n = 3
                cFilter     := 'WildMatch( "*' + Upper(cPattern) + '*", UPPER( CITY )) .AND. !DELETED()'
           elseif  n = 4
                cFilter     := 'WildMatch( "*' + Upper(cPattern) + '*", UPPER( STATE )) .AND. !DELETED()'
             ENDIF



         cSaveFilt   := DBFILTER()
         nRecNo      := RECNO()
         lStay       := &cFilter
         SET FILTER TO &cFilter
         GO TOP
         if OrdKeyCount() == 0
            SET FILTER TO &cSaveFilt
            GO TOP
            DBGOTO( nRecNo )
         else
             (cdbf)->(OrdSetFocus(n))

            cSeek    := cPattern
            oSeek:cText( cSeek )
         oSeek:REFRESH()

            if lStay
               DBGOTO( nRecNo )
               oBrw:Refresh()
            else
               oBrw:Refresh( .t. )
            endif
            lFound   := .t.
         endif
      endif
   endif

return lFound

 



How I can change these lines ?

if n = 1
cFilter := 'WildMatch( "*' + Upper(cPattern) + '*", UPPER( FIRST )) .AND. !DELETED()'
elseif n = 2
cFilter := 'WildMatch( "*' + Upper(cPattern) + '*", UPPER( LAST )) .AND. !DELETED()'
elseif n = 3
cFilter := 'WildMatch( "*' + Upper(cPattern) + '*", UPPER( CITY )) .AND. !DELETED()'
elseif n = 4
cFilter := 'WildMatch( "*' + Upper(cPattern) + '*", UPPER( STATE )) .AND. !DELETED()'
ENDIF
Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)
I use : FiveWin for Harbour November 2023 - January 2024 - Harbour 3.2.0dev (harbour_bcc770_32_20240309) - Bcc7.70 - xMate ver. 1.15.3 - PellesC - mail: silvio[dot]falconi[at]gmail[dot]com
User avatar
Silvio.Falconi
 
Posts: 7056
Joined: Thu Oct 18, 2012 7:17 pm

Re: Multiple search on Xbrowse ( to Mr Nages)

Postby Silvio.Falconi » Fri May 10, 2013 10:52 am

any solution Please ?
Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)
I use : FiveWin for Harbour November 2023 - January 2024 - Harbour 3.2.0dev (harbour_bcc770_32_20240309) - Bcc7.70 - xMate ver. 1.15.3 - PellesC - mail: silvio[dot]falconi[at]gmail[dot]com
User avatar
Silvio.Falconi
 
Posts: 7056
Joined: Thu Oct 18, 2012 7:17 pm


Return to FiveWin for Harbour/xHarbour

Who is online

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