For Programmers: Free Programming Magazines  


Home > Archive > Clipper > September 2006 > Filtering tvrowse









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Filtering tvrowse
jmilovic@gmail.com

2006-09-26, 6:55 pm

I want to filter a tbrowse view, i tried skip block option but it didnt
worked for me. Is there any other way to filter a tbrowse (not using
the set filter command). My database is indexed on two keys
(storage_id)+(item_id) but i want to filter it only on one field
(storage_id).


Thanks.

Gerhard Bunzel

2006-09-27, 6:55 pm

Hi,

try this for your tbrowse-filter. It's very fast also in large files and you
don't need a filter.


private lFilter, cFilter, cFilterBed

lFilter := .T.
cFilter := KUNDEN->KNR // value to filter
cFilterBed := "KNR" // filed to check for your filter

// Add Skipblock to browser
sobj:skipBlock := {|x|Skipper(x)}

// Add GoTop-Block to browser
sobj:GoTopBlock := {||Func_top(lFilter)}

// Add GoBottom-Block to browser
sobj:GoBottomBlock := {||Func_Bot(lFilter)}

lShow := .T.

sobj:freeze := 1
sobj:GoTop()

while(lshow)

sobj:forcestable()
.......

enddo

FUNC FUNC_TOP (lFilter)
memvar cFilter

if lFilter
dbs(cFilter)
else
dbgotop()
endif

RETURN .T.

FUNC FUNC_BOT (lFilter)
local lEndFlag := .F.
memvar cFilter, cFilterBed

if lFilter
do while &cFilterBed = cFilter .and. !lEndFlag
dbskip(100)
if &cFilterBed > cFilter .or. eof()
do while ((!bof()) .or. &cFilterBed # cFilter) .and. !lEndFlag
dbskip(-10)
if bof() .or. (&cFilterBed = cFilter) .or. (&cFilterBed < cFilter)
do while (&cFilterBed = cFilter .or. &cFilterBed < cFilter) .and.
!eof()
dbskip()
enddo
lEndFlag = .T.
if eof()
dbskip(-1)
endif
endif
enddo
endif
enddo
else
dbgobottom()
endif

RETURN .T.

FUNC SKIPPER(n)
local mov := 0,alt_rec := recno()
memvar lFilter, cFilterBed, cFilter

do case
case n > 0
do while mov < n
dbskip()
if eof() .or. (lFilter .and. &cFilterBed # cFilter)
dbgoto(alt_rec)
exit
endif
if !lFilter .or. (lFilter .and. &cFilterBed == cFilter)
alt_rec := recno()
mov++
endif
enddo
case n < 0
do while mov > n
dbskip(-1)
if bof()
dbgoto(alt_rec)
exit
endif
if lFilter .and. &cFilterBed # cFilter
dbgoto(alt_rec)
exit
else
alt_rec := recno()
mov--
endif
enddo
otherwise
dbskip(0)
endcase

RETURN mov


HTH

Gerhard





<jmilovic@gmail.com> schrieb im Newsbeitrag
news:1159293947.477971.200250@b28g2000cwb.googlegroups.com...
> I want to filter a tbrowse view, i tried skip block option but it didnt
> worked for me. Is there any other way to filter a tbrowse (not using
> the set filter command). My database is indexed on two keys
> (storage_id)+(item_id) but i want to filter it only on one field
> (storage_id).
>
>
> Thanks.
>



Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com