MariaDB FWMaria OrdWildSeek (Solved)

MariaDB FWMaria OrdWildSeek (Solved)

Postby ctoas » Tue Feb 09, 2021 1:53 am

Hello friends

I have 2 functions that I used for incremental letter-by-letter search with DBF that I adapted for MariaDB.
In this case, the first first part where I search letter-by-letter is working perfectly, but when I try to go to the next record using the same search string it doesn't work.

Code: Select all  Expand view
oRs := oServer:RowSet( "SELECT nome,r_social FROM agenda ORDER BY r_social" )


Code: Select all  Expand view

       @ 0069,0000 XBROWSE oBrwAGENDA OF oDlgAGENDA SIZE 0520,0230 STYLE FLAT PIXEL NOBORDER DATASOURCE oRS//AUTOSORT   
            
        ADD TO oBrwAGENDA DATA oRs:r_social PICTURE "@!" HEADER "Razão Social" WIDTH 520
        ADD TO oBrwAGENDA DATA oRs:nome     PICTURE "@!" HEADER "Nome"         WIDTH 520                 

        oBrwAGENDA:nColDividerStyle := 0          
        oBrwAGENDA:nRowDividerStyle := 0          
        oBrwAGENDA:nMarqueeStyle    := 5
        oBrwAGENDA:lHScroll         := .F.
        oBrwAGENDA:lVScroll         := .T.
        oBrwAGENDA:lRecordSelector  := .F.
        oBrwAGENDA:bKeyChar         := {|nKey|IIF(nKey==VK_RETURN,((OPERACAO_AGENDA(2))),)}
        oBrwAGENDA:bClrSelFocus      := {||{nRGB(000,000,000),nRGB(150,150,150)}}
        oBrwAGENDA:bClrSel           := {||{nRGB(000,000,000),nRGB(150,150,150)}}
        oBrwAGENDA:bClrStd           := {||{CLR_BLUE,IIF(oRS:KeyNo() %2==0,CLR_WHITE,nRGB(232,232,232))}}
        oBrwAGENDA:nHeaderHeight    := 40
        oBrwAGENDA:bClrHeader       := {||{nRGB(000,000,000),nRGB(150,150,150)}}
        oBrwAGENDA:bSeek            := {|c|.F.}
           
        oBrwAGENDA:aCols[1]:oHeaderFont := ARIAL16B
        oBrwAGENDA:aCols[1]:bLClickHeader := {|r,c,f,o| nil}
        oBrwAGENDA:aCols[2]:oHeaderFont := ARIAL16B  
       
        oBrwAGENDA:CreateFromCode()
 


Here I do the research in a GET
Code: Select all  Expand view
@ 0045,0560 GET oGetPESQUISA VAR cPESQUISA PICTURE "@!" SIZE 0455,0020 PIXEL FONT ARIAL14B OF oBarAGENDA ON CHANGE(PESQUISA(oGetPESQUISA,oBrwAGENDA,oRS))


Button that sends to the next record
Code: Select all  Expand view
@ 0045,1018 BTNBMP oBtnPROXIMO RESOURCE "BTN_PROXIMO" OF oBarAGENDA SIZE 0020,0020 PIXEL FLAT NOBORDER ACTION PROXIMO(cPESQUISA,oBrwAGENDA,oRS)


Search and next functions
Code: Select all  Expand view

********************************************************************************
STATIC FUNCTION PESQUISA(_oGetPesquisa,_oBrwPESQUISA,_oRS)
********************************************************************************

    LOCAL cCHAVEPESQUISA := ""

    cCHAVEPESQUISA:=(_oGetPesquisa:oGet:Buffer)
   
   _oRS:ORDWILDSEEK("*"+ALLTRIM(cCHAVEPESQUISA)+"*",.F.)

    _oBrwPESQUISA:REFRESH()    

RETURN NIL
 


Code: Select all  Expand view

********************************************************************************
STATIC FUNCTION PROXIMO(cPESQUISA,_oBrwPESQUISA,_oRS)
********************************************************************************

    _oRS:ORDWILDSEEK("*"+ALLTRIM(cPESQUISA)+"*",.F.)
   
    IF _oRS:EOF()
        _oRS:DBGOTOP()
    ENDIF
   
    _oBrwPESQUISA:REFRESH()    
                                                     
RETURN NIL
 
Last edited by ctoas on Wed Feb 10, 2021 12:40 pm, edited 1 time in total.
Christiano Augusto Silveira
christiano.silveira@gmail.com

MaxxTech Soluções em TI
http://www.maxxtech.com.br
User avatar
ctoas
 
Posts: 115
Joined: Wed Oct 26, 2005 2:38 pm
Location: São Paulo - Brasil

Re: MariaDB FWMaria OrdWildSeek

Postby nageswaragunupudi » Tue Feb 09, 2021 8:47 pm

Seeking for the first occurrence:
Code: Select all  Expand view
if oRs:OrdWildSeek( cSeek )
   oBrw:Refresh()
else
   MsgInfo( "not found" )
endif


Seeking for the next occurrence:
Code: Select all  Expand view
nSaveRec := oRs:RecNo()
oRs:Skip( 1 )
if oRs:OrdWildSeek( cSeek, .t. )
   oBrw:Refresh()
else
   oRs:GoTo( nSaveRec )
   MsgInfo( "not found"
endif


if oRs:OrdWildSeek(...) succeeds, it returns .T. and if it failed, it returns .F., but does not move the record pointer.
It does not move to Eof() like DBF. So, please do not check for Eof()
Regards

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

Re: MariaDB FWMaria OrdWildSeek

Postby ctoas » Tue Feb 09, 2021 10:37 pm

Hi Nages,

Seeking for the next occurrence:

Code: Select all Expand view
nSaveRec := oRs:RecNo()
oRs:Skip( 1 )
if oRs:OrdWildSeek( cSeek, .t. )
oBrw:Refresh()
else
oRs:GoTo( nSaveRec )
MsgInfo( "not found"
endif


Unfortunately it didn't work, the skip runs, but OrdWildSeek doesn't.
Christiano Augusto Silveira
christiano.silveira@gmail.com

MaxxTech Soluções em TI
http://www.maxxtech.com.br
User avatar
ctoas
 
Posts: 115
Joined: Wed Oct 26, 2005 2:38 pm
Location: São Paulo - Brasil

Re: MariaDB FWMaria OrdWildSeek

Postby nageswaragunupudi » Wed Feb 10, 2021 5:03 am

Whenever you post in the forums, please indicate the version of FWH you are using. That will make it easier for us to support you better.

Please copy this sample program to your fwh\samples folder and build with buildh.bat or buildx.bat. I understand this is the functionality you are looking for.
Code: Select all  Expand view
#include "fivewin.ch"


function Main()

   local oCn, oRs
   local oDlg, oFont, oBrw, oGet, oBtn
   local cSeek := Space( 60 )

   oCn   := FW_DemoDB( 6 )
   oRs   := oCn:RowSet( "select first,last,city from customer" )
   oRs:Sort := "first"

   SetGetColorFocus()

   DEFINE FONT oFont NAME "TAHOMA" SIZE 0,-16
   DEFINE DIALOG oDlg SIZE 700,600 PIXEL TRUEPIXEL FONT oFont

   @ 20, 20 GET oGet VAR cSeek SIZE 300,26 PIXEL OF oDlg UPDATE
   oGet:bChange := <||
      if oRs:OrdWildSeek( "*" + Trim( oGet:oGet:buffer ) + "*" )
         oBrw:Refresh()
      else
         return .f.
      endif
      return nil
      >

   @ 20,350 BTNBMP oBtn PROMPT "NEXT" SIZE 120,30 PIXEL OF oDlg FLAT
   oBtn:bAction := <||
      local nSaveRec := oRs:RecNo()

      oRs:Skip( 1 )
      if oRs:OrdWildSeek( "*" + Trim( cSeek ) + "*", .t. )
         oBrw:Refresh()
      else
         ? "not found"
         oRs:GoTo( nSaveRec )
      endif
      return nil
      >

   @ 60,20 XBROWSE oBrw SIZE -20,-20 PIXEL OF oDlg ;
      DATASOURCE oRs ;
      COLUMNS "first","last","City" ;
      HEADERS "FirstName", "SurName" ;
      COLSIZES 180,180,180 ;
      CELL LINES NOBORDER

   WITH OBJECT oBrw
      :RecSelShowRecNo()
      //
      :CreateFromCode()
   END

   ACTIVATE DIALOG oDlg CENTERED
   RELEASE FONT oFont

   oRs:Close()
   oCn:Close()

return nil
 


Image
Regards

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

Re: MariaDB FWMaria OrdWildSeek (Solved)

Postby ctoas » Wed Feb 10, 2021 12:38 pm

Thanks for the help Nages.

Perfect!
Christiano Augusto Silveira
christiano.silveira@gmail.com

MaxxTech Soluções em TI
http://www.maxxtech.com.br
User avatar
ctoas
 
Posts: 115
Joined: Wed Oct 26, 2005 2:38 pm
Location: São Paulo - Brasil


Return to FiveWin for Harbour/xHarbour

Who is online

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