Hello CSPro Users,
I hope you are all doing ok and happy with the Android news
I have a problem with a scenario: I want to be able to dynamically update value set items: using answers entered by users in a question as value set items for following questions.
My guess is that, I will have to use Logic to alter data dictionary: Is that possible?
Dynamically updating value set items
-
- Posts: 1796
- Joined: December 5th, 2011, 11:27 pm
- Location: Washington, DC
Re: Dynamically updating value set items
It is possible. You have to use the setvalueset function to do this. If you look at the Metro Survey application included with the Android application you can see an example of how this is done:
http://www.csprousers.org/beta/MetroSurvey.7z
http://www.csprousers.org/beta/MetroSurvey.7z
Re: Dynamically updating value set items
Thanks.
Sounds like what I am looking for but I am not sure I understand how this thing works.
The stations have their own dictionary (Stations.dcf) and data file (metro-survey-wmataStations.dat) but how do you update the data?
What's the purpose of the Metro Survey.ent.wrk.dcf dictionary?
I don't understand how the createStationValueset(colorCode) works.
Thank you
Sounds like what I am looking for but I am not sure I understand how this thing works.
The stations have their own dictionary (Stations.dcf) and data file (metro-survey-wmataStations.dat) but how do you update the data?
What's the purpose of the Metro Survey.ent.wrk.dcf dictionary?
I don't understand how the createStationValueset(colorCode) works.
Thank you
-
- Posts: 1796
- Joined: December 5th, 2011, 11:27 pm
- Location: Washington, DC
Re: Dynamically updating value set items
The metro survey application is a more complicated program, so here is a more basic one. See attached, and the following code for how to create a dynamic value set based on selections made in a check box:
PROC GLOBAL
array alpha (20) vsLabels(50);
array vsCodes(50);
numeric ctr;
PROC FAVORITE_MEAT
preproc
do ctr = 1 while ctr <= length(strip(MEATS_CONSUMED))
// ctr - 1 because the dynamic value set begins at position 0, not 1
vsLabels(ctr - 1) = getlabel(MEATS_CONSUMED BY code MEATS_CONSUMED[ctr:1]);
vsCodes(ctr - 1) = ctr;
enddo;
vsCodes(ctr - 1) = notappl; // end the dynamic value set
setvalueset(FAVORITE_MEAT,vsCodes,vsLabels);
setcapturetype(FAVORITE_MEAT,1); // display this as a radio button
postproc
errmsg("Your favorite meat is: %s",getlabel(MEATS_CONSUMED BY code MEATS_CONSUMED[FAVORITE_MEAT:1]));
array alpha (20) vsLabels(50);
array vsCodes(50);
numeric ctr;
PROC FAVORITE_MEAT
preproc
do ctr = 1 while ctr <= length(strip(MEATS_CONSUMED))
// ctr - 1 because the dynamic value set begins at position 0, not 1
vsLabels(ctr - 1) = getlabel(MEATS_CONSUMED BY code MEATS_CONSUMED[ctr:1]);
vsCodes(ctr - 1) = ctr;
enddo;
vsCodes(ctr - 1) = notappl; // end the dynamic value set
setvalueset(FAVORITE_MEAT,vsCodes,vsLabels);
setcapturetype(FAVORITE_MEAT,1); // display this as a radio button
postproc
errmsg("Your favorite meat is: %s",getlabel(MEATS_CONSUMED BY code MEATS_CONSUMED[FAVORITE_MEAT:1]));
- Attachments
-
- setvaluesetWithCheckbox.7z
- (1.61 KiB) Downloaded 380 times
Re: Dynamically updating value set items
Thanks Greg!
I see that this is not as easy as I expected it to be.
I will give it a try and get back to you.
I see that this is not as easy as I expected it to be.
I will give it a try and get back to you.