CMFILTER, CMCLRFILTER

General Help regarding HMG, Compilation, Linking, Samples

Moderator: Rathinagiri

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

CMFILTER, CMCLRFILTER

Post by Pablo César » Thu Feb 02, 2017 9:08 pm

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: 190
Joined: Tue Jul 15, 2014 6:52 pm
Location: The Netherlands
Has thanked: 4 times
Been thanked: 11 times

Post by trmpluym » Thu Feb 02, 2017 10:51 pm

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 69 times

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

Post by Pablo César » Fri Feb 03, 2017 9:43 am

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: 497
Joined: Tue Jun 04, 2013 6:33 pm
Location: Argentina
Been thanked: 23 times

Post by EduardoLuis » Fri Feb 03, 2017 3:58 pm

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: 95
Joined: Fri Jun 13, 2014 7:16 am
Location: Belgium
Been thanked: 1 time

Post by Clip2Mania » Mon Feb 06, 2017 3:46 pm

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

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

Post by ASESORMIX » Mon Feb 06, 2017 6:11 pm

+1

Muchas Gracias.

User avatar
Roberto Lopez
HMG Founder
Posts: 3881
Joined: Wed Jul 30, 2008 6:43 pm
Has thanked: 13 times
Been thanked: 110 times

Post by Roberto Lopez » Tue Feb 07, 2017 4:41 pm

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: 4054
Joined: Wed Sep 08, 2010 1:18 pm
Location: Curitiba - Brasil
Has thanked: 100 times
Been thanked: 175 times

Post by Pablo César » Tue Feb 07, 2017 4:50 pm

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: 186
Joined: Sat Nov 02, 2013 5:42 am
DBs Used: DBF
Been thanked: 6 times

Post by franco » Thu Feb 09, 2017 9:58 pm

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.

User avatar
Roberto Lopez
HMG Founder
Posts: 3881
Joined: Wed Jul 30, 2008 6:43 pm
Has thanked: 13 times
Been thanked: 110 times

Post by Roberto Lopez » Thu Feb 09, 2017 10:38 pm

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