PC SOFT

FORUMS PROFESSIONNELS
WINDEVWEBDEV et WINDEV Mobile

Accueil → WINDEV 2024 → [WD8] HFilter still not working properly?
[WD8] HFilter still not working properly?
Débuté par Clive Dickinson, 05 aoû. 2004 07:16 - 5 réponses
Posté le 05 août 2004 - 07:16
Hello all,
Could someone correct me if I am wrong, but I think the HFilter function still does not work the way it should.
Suppose you have a file with a composite key, say Key_A and Key_B
Suppose you have records in the file with the following values
Record Key_A value Key_B value
1................1................1
2................1................2
3................1................3
4................1................4
5................1................5
6................2................1
7................2................2
8................2................3
9................2................4
10..............3................3
11..............3................4
12..............3................5
Suppose now you build your hfilter with minimum key values Key_A = 1 and Key_B = 3
and maximum key values Key_A = 3 and Key_B = 3
Surely you would expect this to return records 3, 8 and 10. However, it returns records 3 to 10, even if you are using the right composite key.
It appears the second component is only checked for the first and last records. If you wish to verify this, check the 'search on composite keys' example, using the fourth filter (date, code & name).
I hope someone can prove me wrong in this assertion!
Clive
Posté le 05 août 2004 - 09:32
Hello all,
Could someone correct me if I am wrong, but I think the HFilter function still does not work the way it should.
Suppose you have a file with a composite key, say Key_A and Key_B
Suppose you have records in the file with the following values
Record Key_A value Key_B value
1................1................1
2................1................2
3................1................3
4................1................4
5................1................5
6................2................1
7................2................2
8................2................3
9................2................4
10..............3................3
11..............3................4
12..............3................5
Suppose now you build your hfilter with minimum key values Key_A = 1 and Key_B = 3
and maximum key values Key_A = 3 and Key_B = 3
Surely you would expect this to return records 3, 8 and 10. However, it returns records 3 to 10, even if you are using the right composite key.
It appears the second component is only checked for the first and last records. If you wish to verify this, check the 'search on composite keys' example, using the fourth filter (date, code & name).
I hope someone can prove me wrong in this assertion!
Clive

Can you post the code for the hFilter please?
Posté le 05 août 2004 - 12:23
Hi Clive,
Could someone correct me if I am wrong, but I think the HFilter function still
does not work the way it should.

[...]
The HFilter() function is working the way it should work, given from your
example.
>It appears the second component is only checked for the first and last records.
The composite key is handled as just one key and not 2 different fields.
For this case, use a condition in the filter.
pe: HFilter(File, KEY_A, 1, 3, "KEY_B=3")
Greetings
Peter
Posté le 05 août 2004 - 13:54
>Can you post the code for the hFilter please?
Art,
The numbers I quoted were just a hypothetical case. In actual fact the one I was testing is the 'search on a composite key' example from PCSoft. If you look at that example you will see the code for the hfilter on the 4th key. This key is on date, order code and name. If you input a date range - say 8/3/2004 to 8/4/2004 and then input a code range - say 3 to 4, then you would surely expect to get only records which obey both selection criteria. In fact you get records which obey the date selection criteria but not the code criteria.
This does not seem logical to me. If I put both criteria in then I obviously want both selections to operate. Otherwise what is the use of the second one?
Clive
Posté le 05 août 2004 - 14:12
Hi Peter,
Thanks for your reply. I agree with you that the condition option is a way around this. However, this means that using a second key component in a composite key within hfilter has no advantage ie it is redundant.
I would have thought that if you wanted to select all people from a database where the surname is between 'SMITH' and 'SMITHERS' and whose given name is 'GEORGE' then you could set something like (leaving out the hbuildkey & hminvalue etc):
hfilter(file, namekey,'SMITH','SMITHERS','GEORGE','GEORGE')
provided namekey is a composite key on surname and given name
Regards,
Clive

Hi Clive,
The composite key is handled as just one key and not 2 different fields.
For this case, use a condition in the filter.
pe: HFilter(File, KEY_A, 1, 3, "KEY_B=3")
Greetings
Peter
Posté le 06 août 2004 - 23:31
Hi Clive,
Thanks for your reply. I agree with you that the condition option is a way
around this. However, this means that using a second key component in a
composite key within hfilter has no advantage ie it is redundant.

Indeed, for what you want to use it for the composite key is of no use.
I would have thought that if you wanted to select all people from a database
where the surname is between 'SMITH' and 'SMITHERS' and whose given name is
'GEORGE' then you could set something like (leaving out the hbuildkey &
hminvalue etc):
hfilter(file, namekey,'SMITH','SMITHERS','GEORGE','GEORGE')
provided namekey is a composite key on surname and given name

Yes, and if you want also the zipcode, the number of children the 'SMITH...'
have, their profession, ... as a part of the selection?
Greetings,
Peter