Checkbox validation

Discussions about CSEntry
Forum rules
New release: CSPro 8.0
Post Reply
Farhan
Posts: 5
Joined: March 15th, 2018, 9:23 am

Checkbox validation

Post by Farhan »

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.

Regards.

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

PROC S1_1_WHAT_RIGHTS_WOMEN_HAVE // checkbox

postproc

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]);
endif;

enddo;
-----------------------------------------------
Attachments
Proc Global.JPG
Proc Global.JPG (59.24 KiB) Viewed 2947 times
josh
Posts: 2399
Joined: May 5th, 2014, 12:49 pm
Location: Washington DC

Re: Checkbox validation

Post by josh »

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.
Farhan
Posts: 5
Joined: March 15th, 2018, 9:23 am

Re: Checkbox validation

Post by Farhan »

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