Condtional ValueSet

Other discussions about CSPro
Forum rules
New release: CSPro 8.0
Post Reply
Bibek
Posts: 1
Joined: February 23rd, 2018, 10:37 am

Condtional ValueSet

Post by Bibek »

Hi
Any one can help me to set valueSet conditionally in CSPro 6.3.
I have tried to this
PROC GLOBAL
numeric i;
array aDistrictCodes(99);
array alpha(32) aDistrictNames(99);

PROC MYPOGRAM_FF

preproc

{ turn on assisted mode for province and district
to get dialog that shows value set entries }
set attributes(PROVINCE, DISTRICT) assisted on (responses);

{ use lookup file to load all districts for province entered }
PROVINCE_CODE = PROVINCE;
if loadcase(AREA_DICT, PROVINCE_CODE) = 0 then
errmsg("Invalid province, please reenter");
reenter PROVINCE;
endif;

{ Copy the district codes and names for the selected province into arrays.
Note that the AREA_REC record repeats (max occurences of 99) so when we
load the case for a given province, we get one occurence of AREA_REC
for each district in the given province. }
do varying i = 1 until i > count(AREA_DICT.AREA_REC)
{ the arrays that we use for setvalueset start at 0 so we use i-1! }
aDistrictCodes(i-1) = DISTRICT_CODE(i);
aDistrictNames(i-1) = DISTRICT_NAME(i);
enddo;
aDistrictCodes(i-1) = notappl; { mark end of array with a code = notappl
so that setvalueset knows how many elements
in the array to use }

{ call setvalueset using the arrays that contain district codes and names }
setvalueset(DISTRICT, aDistrictCodes, aDistrictNames);

Found Error: Invalid function call (Multiple Record/Group/Item name expected) near line 19 in MYPOGRAM_FF procedure

Thanks in advanced.
josh
Posts: 2399
Joined: May 5th, 2014, 12:49 pm
Location: Washington DC

Re: Condtional ValueSet

Post by josh »

It is hard to tell exactly what the problem when you paste logic into the post like you did since we can't see line numbers. In the future, create a zip file of your application using the pack application tool and add it as an attachment.

Based on the error message it looks like you have the wrong variable name in one of the function calls. I can't tell which one without seeing the line numbers but you should see a red dot next to the line with the problem. Double check that you have spelled the name of the dictionary item exactly the same way it is spelled in the dictionary.

Also, you probably don't want to do this logic in the preproc of MYPROGRAM_FF as that will get run once at program startup before the PROVINCE has been entered. You usually use setvalueset() in the onfocus proc of the variable whose value set you are setting. In this case it would be the onfocus proc of the variable DISTRICT.
Post Reply