How to detect duplicates cases ?

Discussions about CSEntry
Forum rules
New release: CSPro 8.0
Post Reply
thierryt
Posts: 47
Joined: April 26th, 2017, 12:17 pm

How to detect duplicates cases ?

Post by thierryt »

Hi all,
please, i want to know if there is a function whom can indicates that i have a duplicate case when i fill the last question of id-items.
i know that when it is a duplicate case there is a message system 'Case Ids 0001001 duplicate an existing case..', but i want to program it before receive this message.
Thanks !
josh
Posts: 2399
Joined: May 5th, 2014, 12:49 pm
Location: Washington DC

Re: How to detect duplicates cases ?

Post by josh »

You should be able to use the keylist function for this. Get the list of keys from your dictionary and then loop through it to check the ids entered against the list of other ids in the file.See the example for keylist in the help.
Gregory Martin
Posts: 1777
Joined: December 5th, 2011, 11:27 pm
Location: Washington, DC

Re: How to detect duplicates cases ?

Post by Gregory Martin »

If using 7.0 (which you have to for keylist), you can also use the find function on the input dictionary. Construct the potential key as a string, and then do something like this:
if find(INPUT_DICT,=,keyString) then
    errmsg("You've already entered a case with these IDs");
endif;
thierryt
Posts: 47
Joined: April 26th, 2017, 12:17 pm

Re: How to detect duplicates cases ?

Post by thierryt »

Hi Josh, for now i use cspro 6.3, thanks !
thierryt
Posts: 47
Joined: April 26th, 2017, 12:17 pm

Re: How to detect duplicates cases ?

Post by thierryt »

Hi Martin thanks a lot for that solution,
i executed it on killfocus and it is very nice !!!
When i read the help of find function , i was thinking that it is always for external dict, but now i know that i can use it for input dict.
Thanks a lot !
Gregory Martin
Posts: 1777
Joined: December 5th, 2011, 11:27 pm
Location: Washington, DC

Re: How to detect duplicates cases ?

Post by Gregory Martin »

You were right that in the past it was only for external dictionaries. In fact, just this week I updated the help for the find function, so when 7.0 comes out you'll be able to learn about these new features.
Merlino
Posts: 4
Joined: June 1st, 2017, 2:37 pm

Re: How to detect duplicates cases ?

Post by Merlino »

Hi!
As josh said, I tried with keylist but it worked only once and nothing again. It is always the same message of the system ((duplicated case ID...) although I did the same as the following example from CSPro's help

Example 2
PROC GLOBAL

list string enteredKeys;

PROC HOUSEHOLD_NUMBER

keylist(CENSUS_DICT,enteredKeys);

do numeric keyCtr = 1 while keyCtr <= length(enteredKeys)

if HOUSEHOLD_NUMBER = tonumber(enteredKeys(keyCtr)[9:2]) then
errmsg("The household number %d has already been entered.",HOUSEHOLD_NUMBER);
reenter;
endif;

enddo;
josh
Posts: 2399
Joined: May 5th, 2014, 12:49 pm
Location: Washington DC

Re: How to detect duplicates cases ?

Post by josh »

Yes, I just tested this and I see the same problem. It seems that the duplicate ID error message runs before the postproc so there is no way to avoid it.
Merlino
Posts: 4
Joined: June 1st, 2017, 2:37 pm

Re: How to detect duplicates cases ?

Post by Merlino »

Ok josh!
is it possible in a next revision to change some thing about?
josh
Posts: 2399
Joined: May 5th, 2014, 12:49 pm
Location: Washington DC

Re: How to detect duplicates cases ?

Post by josh »

We will look into it.
Post Reply