FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour MariaDB FWMaria OrdWildSeek (Solved)
Posts: 115
Joined: Wed Oct 26, 2005 02:38 PM
MariaDB FWMaria OrdWildSeek (Solved)
Posted: Tue Feb 09, 2021 01: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 (fw): Select all Collapse
oRs := oServer:RowSet( "SELECT nome,r_social FROM agenda ORDER BY r_social" )


Code (fw): Select all Collapse
       @ 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 (fw): Select all Collapse
@ 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 (fw): Select all Collapse
@ 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 (fw): Select all Collapse
********************************************************************************
STATIC FUNCTION PESQUISA(_oGetPesquisa,_oBrwPESQUISA,_oRS)
********************************************************************************

    LOCAL cCHAVEPESQUISA := ""

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

    _oBrwPESQUISA:REFRESH()    

RETURN NIL


Code (fw): Select all Collapse
********************************************************************************
STATIC FUNCTION PROXIMO(cPESQUISA,_oBrwPESQUISA,_oRS)
********************************************************************************

    _oRS:ORDWILDSEEK("*"+ALLTRIM(cPESQUISA)+"*",.F.)
    
    IF _oRS:EOF()
        _oRS:DBGOTOP()
    ENDIF
    
    _oBrwPESQUISA:REFRESH()     
                                                      
RETURN NIL
Christiano Augusto Silveira
christiano.silveira@gmail.com

MaxxTech Soluções em TI
http://www.maxxtech.com.br
Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
Re: MariaDB FWMaria OrdWildSeek
Posted: Tue Feb 09, 2021 08:47 PM
Seeking for the first occurrence:
Code (fw): Select all Collapse
if oRs:OrdWildSeek( cSeek )
   oBrw:Refresh()
else
   MsgInfo( "not found" )
endif


Seeking for the next occurrence:
Code (fw): Select all Collapse
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
Posts: 115
Joined: Wed Oct 26, 2005 02:38 PM
Re: MariaDB FWMaria OrdWildSeek
Posted: 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
Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
Re: MariaDB FWMaria OrdWildSeek
Posted: Wed Feb 10, 2021 05: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 (fw): Select all Collapse
#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


Regards



G. N. Rao.

Hyderabad, India
Posts: 115
Joined: Wed Oct 26, 2005 02:38 PM
Re: MariaDB FWMaria OrdWildSeek (Solved)
Posted: 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

Continue the discussion