CMFILTER, CMCLRFILTER

General Help regarding HMG, Compilation, Linking, Samples

Moderator: Rathinagiri

User avatar
Pablo César
Posts: 4059
Joined: Wed Sep 08, 2010 1:18 pm
Location: Curitiba - Brasil
Has thanked: 100 times
Been thanked: 182 times

CMFILTER, CMCLRFILTER

Post by Pablo César »

Hi Theo,

Could you please attach a practical example please ?
HMGing a better world
"Matter tells space how to curve, space tells matter how to move."
Albert Einstein

trmpluym
Posts: 279
Joined: Tue Jul 15, 2014 6:52 pm
Location: The Netherlands
Has thanked: 9 times
Been thanked: 40 times

Post 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
Attachments
browse_filter4.zip
(1.53 MiB) Downloaded 183 times

User avatar
Pablo César
Posts: 4059
Joined: Wed Sep 08, 2010 1:18 pm
Location: Curitiba - Brasil
Has thanked: 100 times
Been thanked: 182 times

Post by Pablo César »

Really fast ! :P

.. and very easy...

Thank Theo.
HMGing a better world
"Matter tells space how to curve, space tells matter how to move."
Albert Einstein

EduardoLuis
Posts: 665
Joined: Tue Jun 04, 2013 6:33 pm
Location: Argentina
Has thanked: 1 time
Been thanked: 62 times

Post 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

User avatar
Clip2Mania
Posts: 99
Joined: Fri Jun 13, 2014 7:16 am
Location: Belgium
Been thanked: 1 time

Post by Clip2Mania »

Very nice to see that my record collection is still of any use :)

ASESORMIX
Posts: 126
Joined: Thu Oct 25, 2012 8:08 pm
Location: Bqto, Venezuela
Been thanked: 8 times

Post by ASESORMIX »

+1

Muchas Gracias.

User avatar
Roberto Lopez
HMG Founder
Posts: 3987
Joined: Wed Jul 30, 2008 6:43 pm
Has thanked: 27 times
Been thanked: 173 times

Post 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.
Regards/Saludos,

Roberto


(Veritas Filia Temporis)

User avatar
Pablo César
Posts: 4059
Joined: Wed Sep 08, 2010 1:18 pm
Location: Curitiba - Brasil
Has thanked: 100 times
Been thanked: 182 times

Post by Pablo César »

Thanks Roberto for your clarifications.
HMGing a better world
"Matter tells space how to curve, space tells matter how to move."
Albert Einstein

franco
Posts: 465
Joined: Sat Nov 02, 2013 5:42 am
DBs Used: DBF
Been thanked: 18 times

Post 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.
All The Best,
Franco
Canada

User avatar
Roberto Lopez
HMG Founder
Posts: 3987
Joined: Wed Jul 30, 2008 6:43 pm
Has thanked: 27 times
Been thanked: 173 times

Post 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.
Regards/Saludos,

Roberto


(Veritas Filia Temporis)

Post Reply