Add / Remove FILTER from existing DBFILTER()

General Help regarding HMG, Compilation, Linking, Samples

Moderator: Rathinagiri

Post Reply
User avatar
AUGE_OHR
Posts: 2117
Joined: Sun Aug 25, 2019 3:12 pm
DBs Used: DBF, PostgreSQL, MySQL, SQLite
Location: Hamburg, Germany

Add / Remove FILTER from existing DBFILTER()

Post by AUGE_OHR »

hi,

guess i have use

Code: Select all

SET FILTER TO FIELD->AAA = "ABC" .AND. FIELD->BBB = "EFG"
and i want to "add" more ... how under HMG :?:
also how to "remove" Part of DBFOLTER() :?:
have fun
Jimmy
User avatar
mol
Posts: 3825
Joined: Thu Sep 11, 2008 5:31 am
Location: Myszków, Poland
Contact:

Re: Add / Remove FILTER from existing DBFILTER()

Post by mol »

If you want to add something new:
cNewFilter := dbFilter() + ".and." + cExpression
Set Filter to
set filter to cNewFilter

you can use dbClearFilter() instead of SET FILTER TO

for changing something, the best way is removing defined filter and defining it again, in my opinion.
User avatar
AUGE_OHR
Posts: 2117
Joined: Sun Aug 25, 2019 3:12 pm
DBs Used: DBF, PostgreSQL, MySQL, SQLite
Location: Hamburg, Germany

Re: Add / Remove FILTER from existing DBFILTER()

Post by AUGE_OHR »

hi Mol,
mol wrote: Wed Aug 10, 2022 6:49 pm

Code: Select all

cNewFilter := dbFilter() + ".and." + cExpression
Set Filter to
set filter to cNewFilter
hm ... DBFLTER() return String not Codebock as i expect
for changing something, the best way is removing defined filter and defining it again, in my opinion.
you are right, it is (much) more work to "remove" a Part than create a New FILTER
have fun
Jimmy
User avatar
serge_girard
Posts: 3420
Joined: Sun Nov 25, 2012 2:44 pm
DBs Used: 1 MySQL - MariaDB
2 DBF
Location: Belgium
Contact:

Re: Add / Remove FILTER from existing DBFILTER()

Post by serge_girard »

Jimmy,

Maybe this works:

Code: Select all

cNewFilter := dbFilter() + ".and." + &cExpression
or this
cNewFilter := dbFilter() + .and. + &cExpression
Serge
There's nothing you can do that can't be done...
User avatar
mol
Posts: 3825
Joined: Thu Sep 11, 2008 5:31 am
Location: Myszków, Poland
Contact:

Re: Add / Remove FILTER from existing DBFILTER()

Post by mol »

If you have filter expression from dbFilter(), you can easy change it codeblock:

Code: Select all

cNewFilter := "{||" +  dbFilter() +".and." + cExpresion +"}"
bNewFilter := &cNewFilter
Post Reply