logic on multi-occuring field

Discussions about CSEntry
Forum rules
New release: CSPro 8.0
Post Reply
lls
Posts: 109
Joined: December 6th, 2011, 3:11 pm
Location: Geneva, Switzerland

logic on multi-occuring field

Post by lls »

I would like to code the last field of a multi-occuring field, I'm not sure how to do that.
Q145_CONTEXT is the last question of my survey and I would like the case to be automatialy saved as partial if Q11B_ETATDOS is not = 2 and saved if = 2.
Q145_CONTEXT is a 4 occ field, if I use the code below as it is, it will be triggered at every 4 fields.

How can I make the code active only for the last occurence of Q145_CONTEXT?


PROC Q145_CONTEXT

postproc

if not Q11B_ETATDOS = 2 then
errmsg ("This case has been saved as partial") and
savepartial ();
stop();
elseif
errmsg ("This case has been saved")
endif;
Gregory Martin
Posts: 1777
Joined: December 5th, 2011, 11:27 pm
Location: Washington, DC

Re: logic on multi-occuring field

Post by Gregory Martin »

You can use the curocc function like this:
PROC Q145_CONTEXT

postproc

    
if curocc() = 4 then

        
if not Q11B_ETATDOS = 2 then
            
errmsg ("This case has been saved as partial") and
            
savepartial ();
            
stop();
        
        
else
            
errmsg ("This case has been saved")
        
        
endif;
    
    
endif;
lls
Posts: 109
Joined: December 6th, 2011, 3:11 pm
Location: Geneva, Switzerland

Re: logic on multi-occuring field

Post by lls »

Thank you for your advice using the curocc function.

Unfortunately something is not working.
The cases are always saved regardless Q11B_ETATDOS being 2 or an other value.
After the 'stop()' function, the case will not show the icon with a little red cross indicating it had been saved partialy.
lls
Posts: 109
Joined: December 6th, 2011, 3:11 pm
Location: Geneva, Switzerland

Re: logic on multi-occuring field

Post by lls »

Not sure if that is the best solution but replacing postproc by preproc seems to work.
lls
Posts: 109
Joined: December 6th, 2011, 3:11 pm
Location: Geneva, Switzerland

Re: logic on multi-occuring field

Post by lls »

To simplify, I have added a 1-occ field at the end of the survey with the code below.

One more question, is the 'stop()' function mandatory after 'savepartial()' ?
If I remove 'stop()', the case will be saved (not partialy saved).


PROC CLOSECASE

PREPROC

if not Q11B_ETATDOS = 2 then
errmsg ("Ce dossier a été enregistré comme dossier non clos") and
savepartial ();
stop();

else

endif;
Gregory Martin
Posts: 1777
Joined: December 5th, 2011, 11:27 pm
Location: Washington, DC

Re: logic on multi-occuring field

Post by Gregory Martin »

savepartial is usually used for these reasons:

1) Save the case contents when you are working on a huge entry application and are concerned that the power may cut off and you do not want to lose the data entered.

2) If using laptops/tablets for a CAPI application, you may want to semi-regularly save the case.

3) When you are stopping data entry before the end of the questionnaire has been reached. This is typically followed by a stop command.

Do you really want to partially save your case, or is it that you do not want the keyer to enter data for Q145_CONTEXT on the fourth occurrence? If that is the case, you could write:
PROC Q145_CONTEXT

preproc

    
if curocc() = 4 and Q11B_ETATDOS <> 2 then
        
endlevel;
    
endif;
Post Reply