Hi everybody,
I have some experience developing applications in CSPro, but am not a crack. I am using version 6.3.
My questionnaire has three questions, one that asks "what is your first choice" (from a list of about 20 options), a second and a third one that ask for the second and third choice. Those questions use radio buttons as capture type.
Is it possible to, after the first question has been answered, remove the answer from the value set of the second and third question? Etc.
Can value sets be changed by answers to prior questions?
Re: Can value sets be changed by answers to prior questions?
Yes, this is a technique called dynamic value sets. You use the function setvalueset() to modify your value set from logic. See http://teleyah.com/cspro/DCJune2015/04-CAPI/04-CAPI.pdf for a description. You can also look at the simplecapi example in the CSPro examples folder as it does this for the language question. There are also dozens of posts on this forum on the subject. Search for setvalueset.
Re: Can value sets be changed by answers to prior questions?
Thank you very much, Josh, for your quick response!
Re: Can value sets be changed by answers to prior questions?
One follow-up question.
Is there a function that returns the value codes and labels from a value set (e.g into an array)?
Is there a function that returns the value codes and labels from a value set (e.g into an array)?
Re: Can value sets be changed by answers to prior questions?
Unfortunately there is not. If you know the codes you can retrieve the labels using the function getlabel() which gets the label for a particular code. Even if you don't know the values but you know the range, you can loop through the range and call getlabel() on each possible value ignoring the ones with blank labels. Something like:
array codes(10);
array string labels(10);
numeric numCodes = 0;
do numeric i = 1 while i <= 9
string label = getlabel(MYVALUESET_VS, i);
if label <> "" then
numCodes = numCodes + 1;
codes(numCodes) = i;
labels(numCodes) = label;
endif;
enddo;
array string labels(10);
numeric numCodes = 0;
do numeric i = 1 while i <= 9
string label = getlabel(MYVALUESET_VS, i);
if label <> "" then
numCodes = numCodes + 1;
codes(numCodes) = i;
labels(numCodes) = label;
endif;
enddo;
Re: Can value sets be changed by answers to prior questions?
Thank you very much, Josh. That was very helpful!