Page 2 of 3

CMFILTER, CMCLRFILTER

Posted: Thu Feb 02, 2017 9:08 pm
by Pablo César
Hi Theo,

Could you please attach a practical example please ?

Re: CMFILTER, CMCLRFILTER

Posted: Thu Feb 02, 2017 10:51 pm
by trmpluym
Hi Pablo,
Could you please attach a practical example please ?
No problem, here a simple example using cmFilter() and cmClrFilter() combined in a Browse control.

The power is the amazing speed compared to a 'normal' set filter to command. Even with quite large databases the filter works very quick because it takes advantage of the index file.

Theo

Re: CMFILTER, CMCLRFILTER

Posted: Fri Feb 03, 2017 9:43 am
by Pablo César
Really fast ! :P

.. and very easy...

Thank Theo.

Re: CMFILTER, CMCLRFILTER

Posted: Fri Feb 03, 2017 3:58 pm
by EduardoLuis
Hi Theo:

An efficient solution.-
Excellent job.-
This opens multiple searchs on a grid / browse.-
Thanks for your effort and thanks for share it with all of us.-
Eduardo

Re: CMFILTER, CMCLRFILTER

Posted: Mon Feb 06, 2017 3:46 pm
by Clip2Mania
Very nice to see that my record collection is still of any use :)

Re: CMFILTER, CMCLRFILTER

Posted: Mon Feb 06, 2017 6:11 pm
by ASESORMIX
+1

Muchas Gracias.

Re: CMFILTER, CMCLRFILTER

Posted: Tue Feb 07, 2017 4:41 pm
by Roberto Lopez
AFAIR that is the way that FoxPro used to manage SET FILTER, LOCATE FOR and all other commands with a FOR condition.

So, a suggested techique at that time, was to 'cook' the database, meaning, to create indexes for every field that you think could be involved in a search condition.

So, supossedly LOCATE FOR in FoxPro, was faster that Clipper one, if you have the required indexes created.

The way that FOR clause work (using indexes or not) were handeld by SET OPTIMIZE command.

CMFILTER, CMCLRFILTER

Posted: Tue Feb 07, 2017 4:50 pm
by Pablo César
Thanks Roberto for your clarifications.

Re: CMFILTER, CMCLRFILTER

Posted: Thu Feb 09, 2017 9:58 pm
by franco
Hello to all,
I have never found filters work on large tables. That is why I use temp indexes. I hope these temp indexes are not making my black grid.
If I have a table of 100,000 items called table1 with index table1.ntx. I create a temp index from seconds() so it is the only index of this value.
I use ntx indexes... I do
use table1
TFIL:= STR(SECONDS(),9,3)
TFIL := 'tp'+ SUBSTR(TFIL,7,3)
SELECT table1
INDEX ON fieldname TO &TFIL FOR fieldname = your filter'
SET INDEX TO &TFIL , table1.ntx
GO top
program ..............
close table1
tfil := tfil+'.ntx'
delete (tfil)
I have used this for years and it is very fast on big tables. I can add and delete because the tables index(s) are in play.
No data loss for you are in the regular table.
Years ago I tried temporary tables but this was slow and there was a chance for data loss.

Re: CMFILTER, CMCLRFILTER

Posted: Thu Feb 09, 2017 10:38 pm
by Roberto Lopez
franco wrote: Thu Feb 09, 2017 9:58 pm I have never found filters work on large tables. That is why I use temp indexes. I hope these temp indexes are not making my black grid.
<...>
I completely agree with you.

In the last years I've discovered the fact that creating conditional indexes is extremely fast, so I never use filters, I use conditional temporary indexes to show queries instead.