Page 1 of 1
TXBrowse and Filters
Posted: Wed Jan 09, 2008 11:35 am
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.
Filter in XBrowse
Posted: Wed Jan 09, 2008 11:53 am
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
Posted: Wed Jan 09, 2008 4:18 pm
by Detlef Hoefner
in xHarbour you can use dbfScope functions even with dbfntx rdd.
No need to change to another rdd.
Regards,
Detlef
Posted: Wed Jan 09, 2008 4:35 pm
by James Bott
ASK,
Why would you not want to use scopes? That is what they are for.
Regards,
James
Posted: Wed Jan 09, 2008 5:14 pm
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 )
Posted: Thu Jan 10, 2008 8:42 am
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
Posted: Thu Jan 10, 2008 8:53 am
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.
Posted: Thu Jan 10, 2008 9:04 am
by ask
Stefan,
I'm using ntx , but thank you anyway.
regards,
A.S.K