FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour Suggested modification to TDatabase:SetFilter()
Posts: 1096
Joined: Fri Oct 28, 2005 02:27 AM
Suggested modification to TDatabase:SetFilter()
Posted: Thu Dec 08, 2011 02:12 AM
Antonio/Daniel/Rao,

I'd like to recommend :SetFilter() be changed from:
Code (fw): Select all Collapse
METHOD SetFilter( cFilter ) CLASS TDataBase

   ( ::nArea )->( DbSetFilter( Compile( cFilter ), cFilter ) )

return nil


to
Code (fw): Select all Collapse
METHOD SetFilter( cFilter ) CLASS TDataBase
   if empty(cFilter)
      (::nArea)->(dbClearFilter())
   endif
   ( ::nArea )->( DbSetFilter( Compile( cFilter ), cFilter ) )

return nil


This will allow the saving and restoring of filter condition and usable in the form of
Code (fw): Select all Collapse
  oDbf := TDatabase():new()

  cOld := (oDbf:nArea)->(dbfilter())
  oDbf:setFilter("SomeCondition()")
  oDbf:skip()

  oDbf:setFilter(cOld)


Current code would throw an RTE if no pre-existing filter was set because cOld := ""

What do you guys think?
FWH 11.08/FWH 19.12

BCC5.82/BCC7.3

xHarbour/Harbour
Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
Re: Suggested modification to TDatabase:SetFilter()
Posted: Sat Dec 10, 2011 01:58 PM

These methods, like others, in the tdatabase class are implemented to provide the same functionality as their RDD counterpart functions. The intention is that a programmer who is migrating from RDD to TDatabase usage should not find the behavior to be any different.

Regards



G. N. Rao.

Hyderabad, India

Continue the discussion