TXBrowse and Filters

Post Reply
ask
Posts: 99
Joined: Wed Nov 02, 2005 10:40 am

TXBrowse and Filters

Post by ask »

Happy new year to all.

How can i modify bskip , bgotop,bgobottom etc. and make my TXBrowse show only the record i want to see?

e.g.
Code Descr
1 ASK
2 Fivetech
3 Software
4 Test

how can i show code>=2 .and. code<=3 ? I DON'T WANT TO USE Setfilter or Ordscope commands.

Thank in advance

A.S.K.

User avatar
ukoenig
Posts: 3981
Joined: Wed Dec 19, 2007 6:40 pm
Location: Germany
Contact:

Filter in XBrowse

Post by ukoenig »

The best way is, to convert ( if you still using NTX )
to CDX ( Foxpro ).
There is a SCOPE-call ( filter ) for the Index.
That means, when you change the record-position in your
browser, you see only the records, you defined in the SCOPE.
In my sample-collection for xBrowse ( in a few days )
you can see, how it works.

U. König
Since 1995 ( the first release of FW 1.9 )
i work with FW.
If you have any questions about special functions, maybe i can help.
User avatar
Detlef Hoefner
Posts: 312
Joined: Sat Oct 08, 2005 9:12 am
Location: Germany
Contact:

Post by Detlef Hoefner »

in xHarbour you can use dbfScope functions even with dbfntx rdd.
No need to change to another rdd.

Regards,
Detlef
User avatar
James Bott
Posts: 4654
Joined: Fri Nov 18, 2005 4:52 pm
Location: San Diego, California, USA
Contact:

Post by James Bott »

ASK,

Why would you not want to use scopes? That is what they are for.

Regards,
James
User avatar
Biel EA6DD
Posts: 680
Joined: Tue Feb 14, 2006 9:48 am
Location: Mallorca
Contact:

Post by Biel EA6DD »

Like other have suggested, I thing the best and easy solution is using scopes.

If you still don't want to use scope, can do it this way.

Code: Select all

...
   oBrw:bGoTop    := { ||  TopFil( cAlias, cClave ) }
   oBrw:bGoBottom := { ||  Botfil( cAlias, cClave ) }
   oBrw:bSkip     := { | n | SkipFil( cAlias, cClave, n ) }
...
//---------------------------------
FUNCTION SkipFil( cAlias, cKey, nReg )
//---------------------------------
   LOCAL nNext := 0
   DEFAULT nReg := 1
   IF nReg = 0 .OR. ( cAlias ) ->( LastRec() ) = 0 .OR. ! ( &( ( cAlias ) ->( IndexKey( 0 ) ) ) = cKey )
      ( cAlias ) ->( DBSkip( 0 ) )
   ELSEIF nReg > 0 .AND. ( cAlias ) ->( RecNo() ) <> ( cAlias ) ->( LastRec() ) + 1
      DO WHILE nNext <= nReg .AND. ! ( cAlias ) ->( Eof() ) .AND. &( ( cAlias ) ->( IndexKey( 0 ) ) ) = cKey
         ( cAlias ) ->( DBSkip() )
         nNext ++
      ENDDO
      ( cAlias ) ->( DBSkip( - 1 ) )
      nNext --
   ELSEIF nReg < 0
      DO WHILE nNext >= nReg .AND. ! Bof() .AND. &( ( cAlias ) ->( IndexKey( 0 ) ) ) = cKey
         ( cAlias ) ->( DBSkip( - 1 ) )
         nNext --
      ENDDO
      IF ! Bof()
         ( cAlias ) ->( DBSkip() )
      ENDIF
      nNext ++
   ENDIF
   RETURN ( nNext )
//--------------------------
FUNCTION TopFil( cAlias, cKey )
//--------------------------
   ( cAlias ) ->( DBSeek( cKey, .T. ) )
   RETURN NIL
//--------------------------
FUNCTION BotFil( cAlias, cKey )
//--------------------------
   ( cAlias ) ->( DBSeek( Ultima( cKey ), .T. ) )
   ( cAlias ) ->( DBSkip( - 1 ) )
   RETURN NIL
//-----------------------
FUNCTION Ultima( xValue )
//-----------------------
   LOCAL cType := ValType( xValue ), xNext
   DO CASE
   CASE ( cType == "C" )
      xValue := Stuff( xValue, Len( xValue ), 1, ;
                       Chr( Asc( Right( xValue, 1 ) ) + 1 ) )
   CASE ( cType == "N" )
      xValue ++
   CASE ( cType == "D" )
      xValue ++
   ENDCASE
   xNext := xValue
   RETURN( xNext )
Saludos desde Mallorca
Biel Maimó
http://bielsys.blogspot.com/
ask
Posts: 99
Joined: Wed Nov 02, 2005 10:40 am

Post by ask »

ukoenig , Detlef , James , Biel

Thank you all for your reply .The reason that i don't want to use scopes is that i have already allot of source code written with conditions (filters etc) and i want to change my xbrowse to use this conditions and not to change my whole program and start using scopes. As i can see set filter command is very slow. I guess I will try "Biel EA6DD" solution.

Thank you all

A.S.K
StefanHaupt
Posts: 824
Joined: Thu Oct 13, 2005 7:39 am
Location: Germany

Post by StefanHaupt »

Ask,

if you are using cdx, you can also try to replace the standard dbfcdx-rdd with bmdbfcdx that comes with xharbour. It´s working with bitmaps filters and it seems to be faster than the original cdx. You don´t need to change any sourcecode, just link in the lib.
kind regards
Stefan
ask
Posts: 99
Joined: Wed Nov 02, 2005 10:40 am

Post by ask »

Stefan,

I'm using ntx , but thank you anyway.

regards,

A.S.K
Post Reply