FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour XBROWSE Seek Function (Incremental / Wild Seek)
Posts: 336
Joined: Mon Dec 07, 2009 02:49 PM
XBROWSE Seek Function (Incremental / Wild Seek)
Posted: Tue Sep 16, 2025 02:41 PM
Dear Antonio ,


While using `XBROWSE` with **MariaDB rowset** for a Cost Centers list, I observed that when the `cSeek` value does **not exist** in the rowset, subsequent key presses do not behave as expected.
#### Example Rowset (Cost Centers)

AMARAVATI
BANGLORE
DELHI
DEHARADHUN
PUNE
PONDICHERRY

#### Step-by-Step Behavior

1. Press **B** → `cSeek = "B"` → correctly locates **BANGLORE**
2. Press **A** → `cSeek = "BA"` → correctly locates **BANGLORE**
3. Press **C** → `cSeek = "BA"` (unchanged) → stays on **BANGLORE** instead of updating
4. Press **N** → `cSeek` still remains `"BA"` (not `"BAN"`) → fails to locate **BANGLORE**

---

#### Problem Summary

* When the intermediate `cSeek` value (e.g., `"BAC"`) does **not exist** in the rowset,
the variable **does not update correctly**.
* As a result, further key presses fail to refine the seek and navigation breaks.
Please guide me on this. Thanks in advance..!
Thanks

Shridhar

FWH 24.04, BCC 7 32 bit, MariaDB
Posts: 7317
Joined: Thu Oct 18, 2012 07:17 PM
Re: XBROWSE Seek Function (Incremental / Wild Seek)
Posted: Wed Sep 17, 2025 08:51 AM
I hope you understand how the seek of xbrowse works.
This is a simple example.
I cannot provide you with all the accompanying functions because they are proprietary.
function Comuni()
   local oDlg, oBrw,oBar
   local oFont,oBold
   local oIcon

   local cTitle :="Comuni"
   local cPrefix:="Comuni"
   local cSection:="Comuni"

   local oDbf
   local cIniUser :=  cFilePath( GetModuleFileName( GetInstance() ) ) + MEM_FILE_USER
   local cState := GetPvProfString(cSection, "State","", cIniuser)
   local nOrder := VAL(GetPvProfString(cSection, "Order","1", cIniUser))
   local nRecno := VAL(GetPvProfString(cSection, "Recno","1", cIniUser))
   local aCooDlg := aParamDialog(1)
   local nWd  := aCooDlg[1]
   local nHt  := aCooDlg[2]


   local oCursorBtn :=TCursor():New(,'HAND')
   local lCounter:=.t.
   local oColonne
   local lArrows:=.t.
   local lMenu  :=.t.
   local hBmp := LinesBmp()
   local hBmp1 := LinesBmp()
   local hBmp2 := LinesBmp()

   local oSay:=array(2)
   local cSeek:=Space(100)
   local oGet
   local oBtn

   local aBtnBrow:=array(4)
   local oBrush,oBox


   // { field, header, picture, size, justify, sortorder }
   local  aCols    := { ;
                   { "COMUNE",  "Comune"   ,,   120, },;
                   { "PROV",    "Provincia",,   80, },;
                   { "CAP",     "Cap"      ,,   50, },;
                   { "CODREG",  "Regione"  ,,   80, } }

   local nCounter
   local nColMenu

       oDbf:=TComuni():New()
       oDbf:setorder(1)
       oDbf:Gotop()



   DEFINE BRUSH oBrush   STYLE BDIAGONAL COLOR  Rgb(195,195,185)
   DEFINE ICON oIcon RESOURCE "ICON1"


  oFont := TFont():New( "TAHOMA", 0, 14,, )
  oBold := TFont():New( "TAHOMA", 0, 14,,.t. )



   DEFINE DIALOG oDlg SIZE nWd, nHt PIXEL TRUEPIXEL;  // FONT oFont
         COLOR CLR_BLACK, DLG_nColorDlg  ;
       STYLE nOR( DS_MODALFRAME, WS_POPUP, WS_CAPTION, WS_SYSMENU, ;
                  WS_MINIMIZEBOX)   ICON oIcon

       DEFINE BUTTONBAR oBar OF oDlg  SIZE 80,70  TOP NOBORDER  2015

         oBar:bClrGrad := { | lPressed | If( ! lPressed,;
                 { { 1, DLG_nColorBar1, DLG_nColorBar1} },;
                 { { 1, DLG_nColorBar2, DLG_nColorBar2} } ) }


 //------------Search Get

 @ 12,15 say oSay[1] Prompt "Cerca" SIZE 46,24 PIXEL OF oDlg FONT oBold TRANSPARENT
 @ 12,450 say oSay[2] Prompt "in" SIZE 20,24 PIXEL OF oDlg FONT oBold    TRANSPARENT


       @ 10, 165 GET oGet VAR cSeek SIZE 200,19 PIXEL OF oDlg PICTURE "@!" ;
                      BITMAP "CAN_SMALLBRW";
                      ACTION (cSeek    := Space( 100 ),;
                              ChangeGetBtn(oGet,cseek,"CAN_SMALLBRW"),oGet:SetPos(0),;
                              oGet:refresh(),;
                              oBrw:Seek( "" ),oBrw:refresh(),Refresh_title(oBrw,oDlg,oDbf,cTitle))
                      oGet:lBtnTransparent :=.t.
                      oGet:bChange  := { || oGet:Assign() , ChangeGetBtn(oGet,cseek,"CAN_SMALLBRW"),;
                                            oBrw:Seek( cSeek ),oBrw:refresh(),Refresh_title(oBrw,oDlg,oDbf,cTitle) }
                      oGet:bKeyDown := { || oGet:Assign() , ChangeGetBtn(oGet,cseek,"CAN_SMALLBRW") ,;
                                             oBrw:Seek( cSeek ),oBrw:refresh(),Refresh_title(oBrw,oDlg,oDbf,cTitle) }


    @ 103,10 XBROWSE oBrw SIZE -10,-10 PIXEL OF oDlg ;
          DATASOURCE oDbf COLUMNS aCols ;
          AUTOSORT ;       //FONT oFont
          NOBORDER CELL LINES

         oBrw:aCols[ 3 ]:cSortOrder := ""   //no cap
         oBrw:aCols[ 4 ]:cSortOrder := ""   //no REG

          MyStyleBrowse(oBrw,oBrush)



      WITH OBJECT oBrw


       WITH OBJECT  oBrw:aCols[1]
          :nHeadBmpNo := 1
                  :nHeadBmpAlign := AL_LEFT
                 END
             WITH OBJECT  oBrw:aCols[2]
                :oHeaderFont:= oBold
             END
              WITH OBJECT  oBrw:aCols[3]
                :oHeaderFont:= oBold
             END

             WITH OBJECT  oBrw:aCols[4]
                :oHeaderFont:= oBold
             END

             WITH OBJECT  oBrw:aCols[5]
                   :oHeaderFont:= oBold
                   :bEditValue :={ ||  TRegioni():Search( oDbf:codreg ) }
               END



            :lHScroll  := .f.
            :lIncrFilter      := .t.
            :bOnSort          := { |b,oCol| oBrw:Seek( "" ), ;
                                   oBrw:cFilterFld := oCol:cExpr, ;
                                   oBrw:SetFocus() }
            :oSeek := oGet
            :CreateFromCode()
         END

         *oBrw:bCellToolTips := { |o| o:Value }
         * oBrw:aCols[1]:cToolTip := "Premi lo spazio per selezionare"

          oBrw:bRClicked := {|nRow,nCol| Disp_Menu_Comuni(oDlg,nRow,nCol,oDbf,oBrw,cSection,aBtnBrow[4]) }
          oBrw:bEdit:= {|| Edit_Comuni(oBrw,2,oDlg,oDbf,aBtnBrow[4]) }
          oBrw:bKeyDown := {|nKey| Comuni_Tecla(nKey,oBrw,aBtnBrow[4],oDlg,oDbf,cSection) }
          oBrw:RestoreState( cState )


         /*
          oDbf:SetOrder(nOrder)
          if nRecNo < oDbf:LastRec() .AND. nRecno != 0
              oDbf:GoTo(nRecno)
             else
               oDbf:GoTop()
           endif
          */

           //----------------------------------------Buttons

      @ 148, 320  BTNBMP aBtnBrow[1] ;
     RESOURCE "GRID_DWN_REC", "", hBmp, "" ;
      SIZE 15, 13 PIXEL FLAT NOROUND GDIP WHEN lArrows  OF oDlg ;
      ACTION oBrw:KeyDown(VK_DOWN, 0)

   @ 148, 335 BTNBMP  BTNBMP aBtnBrow[2] ;
     RESOURCE "GRID_UP_REC", "", hBmp1, "" ;
      SIZE 15, 13 PIXEL FLAT NOROUND GDIP WHEN lArrows OF oDlg ;
      ACTION oBrw:KeyDown(VK_UP, 0)

   @ 148, 350  BTNBMP aBtnBrow[3] ;
     RESOURCE "GRID_MNU", "", hBmp2, "" ;
      SIZE 15, 13 PIXEL FLAT NOROUND GDIP WHEN lMenu OF oDlg ;
      ACTION ::ShowPopUp( Contextual_Menu( Self,oBrw,oDbf,cIniUser,cSection,oDlg,aBtnBrow[4] ) )



    //------------------- Counter record
          @ oBrw:nBottom+2,  5  BTNBMP aBtnBrow[4] OF oDlg;
                PROMPT (lTrim(tran(oDbf:OrdKeyNo(),'@E 999,999'))+;
                " / "+ltrim(tran( oDbf:OrdKeycount(),'@E 999,999'))) ;
               SIZE 70, 28  PIXEL FLAT NOROUND


              For n= 1 to Iif(lcounter,4,3)
              aBtnBrow[n]:bClrGrad = { | lInvert | If( ! lInvert,;
                    { { 0.25, DLG_nColorBtn1, DLG_nColorBtn2 },;
                      { 0.75, DLG_nColorBtn2, DLG_nColorBtn1 } },;
                    { { 0.25, DLG_nColorBtn2, DLG_nColorBtn1 }, ;
                      { 0.75, DLG_nColorBtn1, DLG_nColorBtn2 } } ) }
              aBtnBrow[n]:nClrBorder := DLG_nColorBtnB
              aBtnBrow[n]:nClrFocusRect := DLG_nColorBar2
              aBtnBrow[n]:nDeepFocusRect := 0
              aBtnBrow[n]:oCursor:=   oCursorBtn
           next

           If lCounter
           aBtnBrow[4]:DISABLE()
           oBrw:bChange  := { || RefreshCont(aBtnBrow[4],oDbf) }
          Endif

          // from 2column
         FOR i := 2 TO Len( oBrw:aCols )
             oCol := oBrw:aCols[ i ]
             oCol:bLDClickData  := {|| Edit_Comuni(oBrw,2,oDlg,oDbf,aBtnBrow[4]) }
         
          NEXT


            //-------------------Combobox for search

    @ 10, 550 COMBOBOX oBrw:oSortCbx VAR oBrw:cSortOrder;
        SIZE 150,400 PIXEL OF oDlg HEIGHTGET 18 STYLE CBS_DROPDOWN

       @ oBrw:nBottom+2, oBrw:nWidth-20 BTNBMP oColonne ;
                FLAT  SIZE 100, 22 OF oDlg   PIXEL ;
                PROMPT TXT_COLUMNS RIGHT ;
                COLOR  CLR_BLACK,nRgb(238,236,219) ;
                BITMAP "SOR_TDW" NOROUND ;
                 ACTION ::ShowPopUp( ColonneMenu( Self,oBrw,oDbf,oDlg,cSection,cIniUser ) )



       oColonne:bClrGrad := { | lInvert | If( ! lInvert,;
                    { { 0.25, RGB( 245,245,235), RGB(250,250,245) },;
                      { 0.75, RGB(250,250,245), RGB( 245,245,235) } },;
                    { { 0.25, RGB(250,250,245), RGB( 245,245,235) }, ;
                      { 0.75, RGB( 245,245,235), RGB(250,250,245) } } ) }
              oColonne:nClrBorder := RGB(195,195,185)
              oColonne:oCursor:= oCursorBtn


   *  oBar:bPainted = { ||;
   *     DrawText2(oBar:hDC,  oFont:hFont, 1, "THIS IS A TEXT ON BUTTONBAR" ,;
   *     10, 420, 500, 500, CLR_HGRAY ) }




       oDlg:bResized  := <||
                  local oRect         := oDlg:GetCliRect()
                  oBrw:nHeight:= oRect:nBottom - 20
                  oSay[1]:setsize(90,   24.2)
                  oSay[1]:nTop        := oRect:ntop+78
                  oSay[1]:nLeft       := oRect:nLeft+10
                  oSay[2]:nTop        := oRect:ntop+78
                  oSay[2]:nLeft       := oRect:nLeft+270
                  oGet:nTop           := oRect:ntop+74
                  oGet:nLeft          := oRect:nLeft+60
                  oGet:setsize(200,   24.2)

                  oBrw:oSortCbx:nTop  := oRect:ntop+74.9
                  oBrw:oSortCbx:nLeft := oRect:nLeft+290

                  oColonne:setsize(90,  25)
                  oColonne:nTop   := oRect:ntop+74
                  oColonne:nLeft  := oRect:nLeft+460

                    aBtnBrow[1]:setsize(30,   24)
                   aBtnBrow[2]:setsize(30,   24)
                   aBtnBrow[3]:setsize(30,   24)

                  aBtnBrow[1]:nTop   := oRect:ntop+74
                  aBtnBrow[1]:nLeft  := oRect:nWidth-100
                  aBtnBrow[2]:nTop   := oRect:ntop+74
                  aBtnBrow[2]:nLeft  := oRect:nWidth-70
                  aBtnBrow[3]:nTop   := oRect:ntop+74
                  aBtnBrow[3]:nLeft  := oRect:nWidth-40


                 IF lCounter
                       aBtnBrow[4]:setsize(90,   24.2)
                       aBtnBrow[4]:nTop     := oRect:ntop+74
                       aBtnBrow[4]:nLeft    := oRect:nWidth-190
                    Endif


                 oBrw:refresh()
                   RETURN nil
                   >



          ACTIVATE DIALOG oDlg  CENTER  NOWAIT;
             ON INIT ( Refresh_title(oBrw,oDlg,oDbf,cTitle),;
                       Btnbar(1,oDlg:oBar,oDlg,oDbf,oBrw,aBtnBrow[4]),;
                       toggle_bmp(oBrw),;
                       oGet:cBmpName:="" , oGet:oBtn:hide(),;
                       oDlg:resize(),ChangeButtons( oDlg:oBar )  ) ;
             VALID (oBrw:nLen := 0 ,;
                    WritePProString(cSection,"State",oBrw:SaveState(),cIniUser),;
                    WritePProString(cSection,"Order",Ltrim(Str(oDbf:OrdNumber())),cIniUser) ,;
                    WritePProString(cSection,"Recno",Ltrim(Str(oDbf:Recno())),cIniUser),;
                    Chiudi_Dbf(oDbf,oDlg:oBar) )


RELEASE  oFont, oBold,oBrush
RETURN NIL
Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)

I use : FiveWin for Harbour March-April 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
Posts: 336
Joined: Mon Dec 07, 2009 02:49 PM
Re: XBROWSE Seek Function (Incremental / Wild Seek)
Posted: Wed Sep 17, 2025 03:59 PM

Dear Silvio ,

So in this case GET control in focus and ON CHANGE of GET XBROWSE Refresh. I tried this but I could not get succeed. I think GET will allow to use back space to ease last key value and search XBROWSE again.  Thanks for the info.

Dear All ,

Any Sample code which I can run quickly and test it. Thanks in advance..!!

Thanks

Shridhar

Thanks

Shridhar

FWH 24.04, BCC 7 32 bit, MariaDB
Posts: 8515
Joined: Tue Dec 20, 2005 07:36 PM
Re: XBROWSE Seek Function (Incremental / Wild Seek)
Posted: Wed Sep 17, 2025 04:41 PM
João Santos - São Paulo - Brasil - Phone: +55(11)95150-7341
Posts: 7317
Joined: Thu Oct 18, 2012 07:17 PM
Re: XBROWSE Seek Function (Incremental / Wild Seek)
Posted: Thu Sep 18, 2025 07:49 AM
shri_fwh wrote: Dear Silvio ,

So in this case GET control in focus and ON CHANGE of GET XBROWSE Refresh. I tried this but I could not get succeed. I think GET will allow to use back space to ease last key value and search XBROWSE again. Thanks for the info.

Dear All ,

Any Sample code which I can run quickly and test it. Thanks in advance..!!

Thanks
Shridhar
send me your little test it is likely that the syntax is wrong

see also on samples folder xbsortcb.prg and xbincflt.prg
Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)

I use : FiveWin for Harbour March-April 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
Posts: 336
Joined: Mon Dec 07, 2009 02:49 PM
Re: XBROWSE Seek Function (Incremental / Wild Seek)
Posted: Thu Sep 18, 2025 03:49 PM

Dear Silvio ,

Thanks for this but I have seen already these examples but do not see any customize bSeek block solution in this its default AUTOSORT. And DBF & Arrays are different than MariaDB Rowset.

Thanks

Shridhar

Thanks

Shridhar

FWH 24.04, BCC 7 32 bit, MariaDB
Posts: 336
Joined: Mon Dec 07, 2009 02:49 PM
Re: XBROWSE Seek Function (Incremental / Wild Seek)
Posted: Fri Sep 19, 2025 04:07 PM
Hi Karinha ,

Thanks for your links , I had tried this but this does not allow to user to use up down arrow along with GET input.
karinha wrote: https://fivetechsupport.com/forums/viewtopic.php?t=43299

https://www.fivetechsupport.com/forums/viewtopic.php?t=36890

https://fivetechsoft.com/forums/viewtopic.php?t=36846

https://fivetechsoft.com/forums/viewtopic.php?f=3&t=39965&p=238550#p238550

Regards, saludos.
Thanks

Shridhar

FWH 24.04, BCC 7 32 bit, MariaDB
Posts: 8515
Joined: Tue Dec 20, 2005 07:36 PM
Re: XBROWSE Seek Function (Incremental / Wild Seek)
Posted: Fri Sep 19, 2025 04:47 PM

Good afternoon, can you post some source code with a rough outline of what you want to do? It'll make it easier to help, right?

Buenas tardes, ¿podrías publicar el código fuente con un esquema general de lo que quieres hacer? Será más fácil ayudar, ¿verdad?

Gracias, tks.

Regards, saludos.

João Santos - São Paulo - Brasil - Phone: +55(11)95150-7341

Continue the discussion