Is Xbrowse Barget still intended to filter data

Is Xbrowse Barget still intended to filter data

Postby Marc Venken » Sat Nov 05, 2022 1:33 pm

At a given time, Mr. Rao introduced the Barget data into Xbrowse. As far as I remember, it was the intension to give us the option to filter data from any field that we wanted to.
We have the option to run a function that we make to process the data.

I started to use it for every Xbrowse i have in use and it is working pretty well. The point is that I use a filter to collect the data and not a scooped filter/index
So maybe my function is not that optimised for the use I have. I do use several fields for a filter to work and these fields not always have indexes. Maybe the should ?

Should I consider having a extended call to the function marc_setfilter(oBrwsel,"CustName") and insite the function make a selection for using scoped or filtered data


do case
case cData = "CustName"
... set index name
... scope the data for quick access
case cData = "CustStreet"
set index street
scope the data
otherwise // more fields have been filled in, so filtering will be a better option
do the filter stuff
endcase



here is my current filtercode :

Code: Select all  Expand view


   //  From insite the Xbrowse setup

   oBrwSel:lGetBar   := .T.  // Button to activate
   if len(aBarget)>0
      FOR EACH cCol in aBarget
         WITH OBJECT oBrwSel:oCol( cCol )
            :uBarGetVal    := uValBlank( :Value )
            :cBarGetPic    := :cEditPicture
            :bClrEdit      := {|| { CLR_BLACK, MY_LIGHTYELLOW } }
            :lBarGetOnKey := .T. // after having setfocus the oBrowse object, the end user can insert the characters directly into the get
            :bBarGetAction := {|| ( oBrwSel:cAlias )->( MARC_SETFILTER( oBrwSel ) ) } // this for show the bitmap on the get and associated a action
         END
      NEXT
   endif

//

FUNCTION MARC_SETFILTER( oBrw )

   LOCAL cFilter := ""
   LOCAL n, oCol, uVal, cType

   FOR n := 1 TO Len( oBrw:aCols )

      oCol  := oBrw:aCols[ n ]
      IF ! Empty( uVal := oCol:uBarGetVal )
         IF !Empty( cFilter )
            cFilter  += " .AND. "
         ENDIF
         cType    := ValType( uVal )
         DO CASE
         CASE cType == 'C'
            uVal     := Upper( AllTrim( uVal ) )
            cFilter += '"' + uVal + '" $ UPPER( ' + oCol:CExpr + " )"

            //  for data starting with text
            //cFilter += "UPPER( " + oCol:cExpr + " ) = '" + uVal + "'"

            //  for data EXACT
            //cFilter += "UPPER( ALLTRIM( " + oCol:cExpr + " ) ) == '" + uVal + "'"

         CASE cType == 'D'
            cFilter  += oCol:cExpr + " = " + ( uVal )
         OTHERWISE
            cFilter  += oCol:cExpr + " == " + cValToChar( uVal )
         ENDCASE
      ENDIF

   NEXT

   IF Empty( cFilter )

      IF ! Empty( dbFilter() )
         dbClearFilter()
         oBrw:Refresh()
      ENDIF

   ELSE

      IF !( dbFilter() == cFilter )
         SET FILTER TO &cFilter
         GO TOP
         oBrw:Refresh()
      ENDIF

   ENDIF

   oBrw:SetFocus()

RETURN NIL

 
Marc Venken
Using: FWH 23.04 with Harbour
User avatar
Marc Venken
 
Posts: 1425
Joined: Tue Jun 14, 2016 7:51 am
Location: Belgium

Re: Is Xbrowse Barget still intended to filter data

Postby nageswaragunupudi » Sat Nov 05, 2022 3:17 pm

BarGet's purpose is not just for filtering. This helps us to GET some value and it is for us to do whatever with that Value, whether we use for filter or for seek or for setting scopes or for whatever purpose.

Do not underestimate filters.
Scope has limited scope. What I mean is scopes are not useful for every occassion.
Most important thing is we should study how to make fully or greatly optimize filters.

With XBrowse, less the code we write the better
Regards

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

Re: Is Xbrowse Barget still intended to filter data

Postby Marc Venken » Sat Nov 05, 2022 4:06 pm

nageswaragunupudi wrote:BarGet's purpose is not just for filtering. This helps us to GET some value and it is for us to do whatever with that Value, whether we use for filter or for seek or for setting scopes or for whatever purpose.

Do not underestimate filters.
Scope has limited scope. What I mean is scopes are not useful for every occassion.
Most important thing is we should study how to make fully or greatly optimize filters.

With XBrowse, less the code we write the better


You are totaly right, and we have spoken before that study of filters is important. I went true many many postings and find pieces of filtering/scoping and went for info with other member in FW Forum.
But still there a pieces missing to do it fully right.... It is hard and many even the most important thing in ALL FWH programming, since it is all DATA that we need to process.
Maybe a time will come for a extra tutorial "The best way for filtering data in FWH, by FW-Team" (for Christmas :D :D )
Just kidding....
Marc Venken
Using: FWH 23.04 with Harbour
User avatar
Marc Venken
 
Posts: 1425
Joined: Tue Jun 14, 2016 7:51 am
Location: Belgium


Return to FiveWin for Harbour/xHarbour

Who is online

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