Page 1 of 1

Function for a sensitive search

Posted: Sun May 04, 2025 11:18 pm
by Diego Euri Almanzar
Hello, dear friends.

I would like to use DC_FINDBROWSE() or any other Express function for a sensitive search. I notice that when I use DC_FINDBROW(), the search is performed using the first positions of the text or field. However, the searched character is often not at the beginning of the text. It could be in the middle, or at the end, etc.

Would it be possible to use Express or Xbase++ for a search that returns the largest number of results, regardless of the position of the searched character?

For example:

White Eagle of the North

If I type "of the" with DC_FINDBROWSE(), I don't get any results. And I would like the result to be White Eagle of the North, because "of the" is contained in the field.

I would appreciate your help.

Best regards.

Re: Function for a sensitive search

Posted: Mon May 05, 2025 5:36 am
by Wolfgang Ciriack
Hello,

you can use the DC_BrowseAutoSeek function with:

Code: Select all

   without ADS:   bSeekBlock := {|a|  ordwildseek("*"+alltrim(upper(a))+"*"), DC_GetRefresh(oBtWs), .T.}
   with ADS:      bSeekBlock := {|a| cfilter := "{|| contains(<your dbf fieldname>,'*"+a+"*'),'*"+a+"*')}", bfilter := &cfilter, ;
         	                                    (sel)->(DbSetFilter(bfilter)), (sel)->(DbGoTop()), DC_GetRefresh(oBtWs), .T.}

   @1,20 DCSAY "Suche:" GET Suchstr  PICTURE "@K !!!!!!!!!!!!" ;
         KEYBLOCK {|a, b, o| DC_BrowseAutoSeek(a, o, oBrowse, , , , , 0.01, bSeekBlock, , .T.)} ;
         TABSTOP ;
         GETOBJECT oSuch ;
         GETID "IDSUCH" ;
         SAYRIGHT

   @2.5, 1 DCBROWSE oBrowse SIZE 40, 20 ;
        DATA cAlias ;
        .......
without ADS you can add a button "continue search" which only do a ACTION {|| OrdWildSeek(), oBrowse:RefreshAll()}

Re: Function for a sensitive search

Posted: Mon May 05, 2025 9:09 am
by rdonnay
I recommend looking at \exp20\samples\browsequery\browsequery.prg.

This uses wildcards and DC_SetScopeArray().

Re: Function for a sensitive search

Posted: Mon May 05, 2025 10:28 pm
by Diego Euri Almanzar
Hello, Wolfgang Ciriack, rdonnay,

Very interesting.

Thank you.