Dynamic Value Sets from Checkboxes
Posted: November 21st, 2017, 4:42 am
Hello CSPRO community, I want to set checkbox for my survey for a variable with value sets ranging from 1 to 13. Attached is the survey for your perusal and help.
I was able to do the following coding but still getting error:
[ERROR: Cannot create alpha variable - symbol name already exists near line 12 in INFORMATION_TOPICS procedure] I cann't seem to figure out what might be wrong. The coding is as follows:=
PROC INFORMATION_TOPICS
onfocus
// Create value set from items selected in INFORMATION TOPICS
numeric nextEntry = 1;
// Used to translate from checkbox (alpha codes) to numeric codes
string INFORMATIONCheckboxCodes = "12345678910111217";
// Loop through the numeric codes 1-13 and each selected
// to value set
do numeric INFORMATIONNumericCode = 1 while INFORMATIONNumericCode <= 17
// Convert the numeric code to the checkbox alpha code
// by looking it up in the array.
string INFORMATIONCheckboxCodes = INFORMATIONCheckboxCodes[INFORMATIONNumericCode:1];
// Check if the INFORMATION TOPIC is selected in the checkbox field
if pos(INFORMATIONCheckboxCodes, S4Q7) > 0 then
// INFORMATION TOPIC is selected. Add it to the value set.
codes(nextEntry) = INFORMATIONNumericCode;
labels(nextEntry) = getlabel(INFORMATION_TOPICS_VS1, INFORMATIONNumericCode);
nextEntry = nextEntry + 1;
endif;
enddo;
// Mark end of value set
codes(nextEntry) = notappl;
// Modify value set
setvalueset(INFORMATION_TOPICS, codes, labels);
I was able to do the following coding but still getting error:
[ERROR: Cannot create alpha variable - symbol name already exists near line 12 in INFORMATION_TOPICS procedure] I cann't seem to figure out what might be wrong. The coding is as follows:=
PROC INFORMATION_TOPICS
onfocus
// Create value set from items selected in INFORMATION TOPICS
numeric nextEntry = 1;
// Used to translate from checkbox (alpha codes) to numeric codes
string INFORMATIONCheckboxCodes = "12345678910111217";
// Loop through the numeric codes 1-13 and each selected
// to value set
do numeric INFORMATIONNumericCode = 1 while INFORMATIONNumericCode <= 17
// Convert the numeric code to the checkbox alpha code
// by looking it up in the array.
string INFORMATIONCheckboxCodes = INFORMATIONCheckboxCodes[INFORMATIONNumericCode:1];
// Check if the INFORMATION TOPIC is selected in the checkbox field
if pos(INFORMATIONCheckboxCodes, S4Q7) > 0 then
// INFORMATION TOPIC is selected. Add it to the value set.
codes(nextEntry) = INFORMATIONNumericCode;
labels(nextEntry) = getlabel(INFORMATION_TOPICS_VS1, INFORMATIONNumericCode);
nextEntry = nextEntry + 1;
endif;
enddo;
// Mark end of value set
codes(nextEntry) = notappl;
// Modify value set
setvalueset(INFORMATION_TOPICS, codes, labels);