Page 1 of 1
getvaluelabel
Posted: September 25th, 2023, 11:07 pm
by VirtuesArios
Hello CSPro users,
I've just wanna ask on how to get value label its on the attached images, what I want to get is the name of the illness but it seems the value came out is AB..so on. Any suggestion would be highly appreciated, Thanks in advance.
Images:
1. Dictionary
2. CAPI Questions
3. Above Image (Choices)
4. Below Image (Results)
Re: getvaluelabel
Posted: September 26th, 2023, 9:28 am
by Gregory Martin
The getvaluelabel function isn't looking at the capture type (checkbox), so it's not formatting your checked options appropriately. You can do something like this in your question text: ~~GetCheckboxLabel()~~
And then add a user-defined function:
function string GetCheckboxLabel()
string labels;
do numeric ctr = 1 while ctr <= I1MULTI_VS1.codes.length()
if ischecked(I1MULTI_VS1.codes(ctr), I1MULTI) then
// add a comma between each entry
if labels <> "" then
labels = labels + ", ";
endif;
labels = labels + I1MULTI_VS1.labels(ctr);
endif;
enddo;
exit labels;
end;
Re: getvaluelabel
Posted: October 6th, 2023, 9:41 am
by VirtuesArios
Gregory Martin wrote: September 26th, 2023, 9:28 am
The getvaluelabel function isn't looking at the capture type (checkbox), so it's not formatting your checked options appropriately. You can do something like this in your question text: ~~GetCheckboxLabel()~~
And then add a user-defined function:
function string GetCheckboxLabel()
string labels;
do numeric ctr = 1 while ctr <= I1MULTI_VS1.codes.length()
if ischecked(I1MULTI, I1MULTI_VS1.codes(ctr)) then
// add a comma between each entry
if labels <> "" then
labels = labels + ", ";
endif;
labels = labels + I1MULTI_VS1.labels(ctr);
endif;
enddo;
exit labels;
end;
Thank you Gregory Martin for replying to my problem and I am sorry it takes me long to reply, but it seems when I try to apply the code that you give me it return blank.
Re: getvaluelabel
Posted: October 9th, 2023, 9:14 pm
by sherrell
Greg is out this week so let me respond. I haven't used the codes and labels feature, but it should be working. In the interim, you can do this, which is working for me:
function string GetCheckboxLabel()
string labels;
do numeric ctr = 1 while ctr <= length(strip(I1MULTI)) // I1MULTI_VS1.codes.length()
alpha(1) letter = I1MULTI[ctr:1];
if ischecked(letter, I1MULTI) then
// add a comma between each entry
if labels <> "" then
labels = labels + ", ";
endif;
labels = labels + getlabel (I1MULTI, letter);
endif;
enddo;
exit labels;
end;
Re: getvaluelabel
Posted: October 12th, 2023, 10:27 pm
by VirtuesArios
Thanks sherrell for the response.
sherrell wrote: October 9th, 2023, 9:14 pm
Greg is out this week so let me respond. I haven't used the codes and labels feature, but it should be working. In the interim, you can do this, which is working for me:
function string GetCheckboxLabel()
string labels;
do numeric ctr = 1 while ctr <= length(strip(I1MULTI)) // I1MULTI_VS1.codes.length()
alpha(1) letter = I1MULTI[ctr:1];
if ischecked(letter, I1MULTI) then
// add a comma between each entry
if labels <> "" then
labels = labels + ", ";
endif;
labels = labels + getlabel (I1MULTI, letter);
endif;
enddo;
exit labels;
end;
Re: getvaluelabel
Posted: November 4th, 2023, 9:08 am
by VirtuesArios
Hi sherrell, I was just wondering it works on the first and second checkbox(e.g. Diabetes and Heart disease) but when I change the answer to another illness it would only display one illness or it would not display at all, what would I change for this to work on all checkbox.
sherrell wrote: October 9th, 2023, 9:14 pm
Greg is out this week so let me respond. I haven't used the codes and labels feature, but it should be working. In the interim, you can do this, which is working for me:
function string GetCheckboxLabel()
string labels;
do numeric ctr = 1 while ctr <= length(strip(I1MULTI)) // I1MULTI_VS1.codes.length()
alpha(1) letter = I1MULTI[ctr:1];
if ischecked(letter, I1MULTI) then
// add a comma between each entry
if labels <> "" then
labels = labels + ", ";
endif;
labels = labels + getlabel (I1MULTI, letter);
endif;
enddo;
exit labels;
end;
Re: getvaluelabel
Posted: November 6th, 2023, 11:17 am
by sherrell
I've made two passes.
In the first app, you can pass a pointer to a function that makes the evaluation, but you'll just need to create a function for each variable you want to analyze.
In the second app (v2, after consult with Greg

), you can pass a valueset in as a function argument. However since the variable is a string, we have to identify the valueset as being for a string, not numeric (as it expects by default).
Sherrell