TXBrowse and Filters

TXBrowse and Filters

Postby ask » Wed Jan 09, 2008 11:35 am

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.

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

Filter in XBrowse

Postby ukoenig » Wed Jan 09, 2008 11:53 am

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
ukoenig
 
Posts: 4043
Joined: Wed Dec 19, 2007 6:40 pm
Location: Germany

Postby Detlef Hoefner » Wed Jan 09, 2008 4:18 pm

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

Regards,
Detlef
User avatar
Detlef Hoefner
 
Posts: 312
Joined: Sat Oct 08, 2005 9:12 am
Location: Germany

Postby James Bott » Wed Jan 09, 2008 4:35 pm

ASK,

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

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

Postby Biel EA6DD » Wed Jan 09, 2008 5:14 pm

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  Expand view
...
   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/
User avatar
Biel EA6DD
 
Posts: 682
Joined: Tue Feb 14, 2006 9:48 am
Location: Mallorca

Postby ask » Thu Jan 10, 2008 8:42 am

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
ask
 
Posts: 99
Joined: Wed Nov 02, 2005 10:40 am

Postby StefanHaupt » Thu Jan 10, 2008 8:53 am

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
StefanHaupt
 
Posts: 824
Joined: Thu Oct 13, 2005 7:39 am
Location: Germany

Postby ask » Thu Jan 10, 2008 9:04 am

Stefan,

I'm using ntx , but thank you anyway.

regards,

A.S.K
ask
 
Posts: 99
Joined: Wed Nov 02, 2005 10:40 am


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 75 guests