Checkbox validation

Discussions about CSEntry
Posts: 4
Joined: March 15th, 2018, 9:23 am

Checkbox validation

Postby Farhan » March 15th, 2018, 10:08 am

Hi everyone ! am new to cspro ... just started working on cspro few days back.

I've this code for checkbox selected values validation , value list consists 01,02,03,04,05,06,..
this detects wrong keyed values ...
how to convert this procedure to global function ? so that i can pass checkbox variable name dynamically.


---- here's the code -----------------------



numeric i ;
numeric start = 0;

do i = 1 while i <= length(strip(S1_1_WHAT_RIGHTS_WOMEN_HAVE))
start = ( i * 2 ) - 1;

if not invalueset(S1_1_WHAT_RIGHTS_WOMEN_HAVE[start:2]) then
errmsg("%s is not a valid option. Please review your selections.",S1_1_WHAT_RIGHTS_WOMEN_HAVE[start:2]);

Proc Global.JPG
Proc Global.JPG (59.24 KiB) Viewed 156 times

Posts: 1448
Joined: May 5th, 2014, 12:49 pm
Location: Washington DC

Re: Checkbox validation

Postby josh » March 15th, 2018, 8:44 pm

The problem is that when you use invalueset inside a function, CSPro can no longer which value set you are referring to. When you use invalueset inside the proc of a dictionary item and you don't specify the value set, CSPro defaults to using the first value set of the variable for the proc you are in. However, in a function in the global it doesn't which value set to choose.

It is possible to pass a value set name to invalueset as the second parameter, however, there is no way to pass the value set name to your validate_checkbox. CSPro user defined functions only accept string and numeric parameters. You can't pass a value set to a user defined function which is what you would need to do to generalize this.

If you know that the values in the value set will always be consecutive, you could pass the min and max values of the range to your validate_checkbox and instead of using invalueset you could check if the values are within that range.

Posts: 4
Joined: March 15th, 2018, 9:23 am

Re: Checkbox validation

Postby Farhan » March 16th, 2018, 2:34 am

thank you josh for describing this limitation of user functions.
Take care.

Return to “Entry”