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 !
How to detect duplicates cases ?
Re: How to detect duplicates cases ?
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.
-
- Posts: 1801
- Joined: December 5th, 2011, 11:27 pm
- Location: Washington, DC
Re: How to detect duplicates cases ?
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;
errmsg("You've already entered a case with these IDs");
endif;
Re: How to detect duplicates cases ?
Hi Josh, for now i use cspro 6.3, thanks !
Re: How to detect duplicates cases ?
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 !
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 !
-
- Posts: 1801
- Joined: December 5th, 2011, 11:27 pm
- Location: Washington, DC
Re: How to detect duplicates cases ?
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.
Re: How to detect duplicates cases ?
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;
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;
Re: How to detect duplicates cases ?
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.
Re: How to detect duplicates cases ?
Ok josh!
is it possible in a next revision to change some thing about?
is it possible in a next revision to change some thing about?
Re: How to detect duplicates cases ?
We will look into it.