using the sysparm() function

Discussions about CSEntry
Post Reply
mashour
Posts: 14
Joined: October 13th, 2015, 10:26 am

using the sysparm() function

Post by mashour »

Hi,

I am using a menu/launcher to direct my enumerator to one of 8 questionnaires. In most of the 8 questionnaires, the case id will be a 5 digit ID which I have them enter in the launcher. I used the sysparm() function to pass this 5 digit ID onto the other questionnaires when the pff launches. I encountered two problems:

1) as soon as one case is saved, another case would automatically be added and that would cause the sysparm() function to pass that same ID to the new case resulting in a duplicates error! I solved this problem by adding a stop(1) function in the postproc of the questionnaire. That way the data entry program closes in between cases, and every new case that is added will have the unique ID entered in the launcher.

2) even though i solved the previous problem, now I have an issue where if the enumerator decides to pause a case and renter another completed one, the sysparm() function causes the case id of the completed case to change! Is there a function (similar to the ispartial function) that can return if a case is completed? and that way I could do something like:
PROC IDVAR
preproc
if iscomplete() then
skip to othervar;
else
idvar=sysparm("ID")
endif;

That might be the wrong way to think about this so I am open to a totally different suggestion :)

Thanks,
M
josh
Posts: 2401
Joined: May 5th, 2014, 12:49 pm
Location: Washington DC

Re: using the sysparm() function

Post by josh »

You can use "AutoAdd=No" in the "[DataEntryInit]" section of the .pff you write out to prevent CSPro from starting the next case automatically. This is an alternative solution to using the stop(1).

For the second problem, you can ignore the sysparm() if the case is opened in modify mode by using the demode() function. Alternatively you can check to see if the id has already been filled in and only fill it in if it is not blank. If you are using system controlled mode you made need to use visualvalue() for this to work e.g. if (visualvalue(MYID) == notappl then MYID=sysparm() endif.

Josh
mashour
Posts: 14
Joined: October 13th, 2015, 10:26 am

Re: using the sysparm() function

Post by mashour »

Thanks Josh!!
I had actually tried a variation of what you suggested and it didn't work, which is why I was looking for the demode() function.
I tried using if statements and the universe function but neither seemed to work...

PROC IDVAR
preproc
universe special(IDVAR);
$ = tonumber(sysparm("ID"));

demode() worked like a charm though, so thanks for that!! I'm just curious though why the above wouldn't work?
josh
Posts: 2401
Joined: May 5th, 2014, 12:49 pm
Location: Washington DC

Re: using the sysparm() function

Post by josh »

The universe will work if you use visualvalue(). Since you are in the preproc of the item that is in the universe, it will be blank (notappl) when you do to the universe test in the preproc. The value doesn't get registered until the start of the postproc. Try:
PROC IDVAR
preproc
universe visualvalue(IDVAR) = notappl;
$ =
tonumber(sysparm("ID"));
mashour
Posts: 14
Joined: October 13th, 2015, 10:26 am

Re: using the sysparm() function

Post by mashour »

thanks! that is really helpful, because I've faced this problem (of being in the preproc) and i didn't know about visualvalue()!
Post Reply