Check Box with 249 Options

Discussions about CSEntry
Post Reply
Stavros
Posts: 33
Joined: February 17th, 2014, 9:12 am

Check Box with 249 Options

Post by Stavros »

Hi all,

I want to have a check_box in my program with 249 options which are actually 249 countries. My issue is that since in order to have a check_box I need to have an alphanumerical item, but the letters of the alphabet are not enough for my value_set. I tried to have the values like C1,C2,C3....C249. CSPro though does not allow me to have the field as a check_box; can that be because of the use of numbers in the value_set? I thought by using "C" in front I would avoid that but apparently not. Has anyone stumbled upon a similar issue? Any ideas how to code the value_set?

Best,
Stavros
Gregory Martin
Posts: 1796
Joined: December 5th, 2011, 11:27 pm
Location: Washington, DC

Re: Check Box with 249 Options

Post by Gregory Martin »

Are you sure that it doesn't work? It worked for me with a test of 195 countries. I used hex codes for each country. You'll probably want to keep the code for each checkbox value a certain width. In this case, each code was two characters. See the attached example.
Attachments
countriesCheckbox.7z
(2.93 KiB) Downloaded 569 times
Stavros
Posts: 33
Joined: February 17th, 2014, 9:12 am

Re: Check Box with 249 Options

Post by Stavros »

Thanks a lot Gregory! Apparently my mistake was that I was keeping the length as 249 and not 249*2 (if using a two character code).
fizz
Posts: 1
Joined: January 19th, 2015, 11:27 am

Re: Check Box with 249 Options

Post by fizz »

Gregory Martin wrote:Are you sure that it doesn't work? It worked for me with a test of 195 countries. I used hex codes for each country. You'll probably want to keep the code for each checkbox value a certain width. In this case, each code was two characters. See the attached example.
hi gregory, i'm wondering what do you mean by hex codes for the choices. when i looked at your attachment, i found that you use codes like 01,02,...,0A,0B,...,10,11,...,etc. i don't think i know any other logic to control these choices without using pos function. so if i want to check whether the question is answered with two choices e.g. 0110. pos function will return true value if i write something like

if pos("11",var1)<>0
i assume it is "true" even when we don't pick choice "11". so i came up with codes like A0,A1,...,A9,B0,B1,...,B9,etc. therefore we have 26 times 10 available choices without a possibility to misread the answer. what do you think?

thanks in advance
Gregory Martin
Posts: 1796
Joined: December 5th, 2011, 11:27 pm
Location: Washington, DC

Re: Check Box with 249 Options

Post by Gregory Martin »

fizz,

Unfortunately, it's a pain to work with checkboxes in CSPro. However, you can still check if a value was selected using the pos function. What you need to do is check the offset of the returned value.

For example, selected values if using a single character for the checkbox value will come at 1, 2, 3, ...

If using two characters for the checkbox value, then the valid offsets are 1, 3, 5, ...

So if using more than one character, you can take the remainder of the value that pos returns and check if it is 1. If it is, then you have a match. In that above example, the remainder of 1 / 2 is 1, 3 / 2 is 1, and 5 / 2 is 1. So you would write:
if pos("11",VAR1) % 2 = 1 then
    
errmsg("11 was selected!");
endif;
Post Reply