Add extra option in array

Discussions about CSEntry
Post Reply
khurshid.arshad
Posts: 572
Joined: July 9th, 2012, 11:32 am
Location: Islamabad, Pakistan

Add extra option in array

Post by khurshid.arshad »

Dear Team

I am using this code from example and i want add extra code in the end for "Do't Know" after populate the list.
aDistrictCodes(i-1) = 999;
aDistrictNames(i-1) = "Don't Know";


Thanks.
arshad

Code: Select all

Preproc

{ use lookup file to load all sectors for district entered }
	LF_DISTRICT_ID = Q_1_2;
	if loadcase(SECTOR_DICT, LF_DISTRICT_ID) = 0 then
		errmsg("Invalid District, please reenter");
		Move to  Q_1_2;
	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(SECTOR_DICT.SECTOR_REC)
		{ the arrays that we use for setvalueset start at 0 so we use i-1! }
		aDistrictCodes(i-1) = LF_SEC_ID(i);
		aDistrictNames(i-1) = LF_SEC_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(Q_2_3_4, aDistrictCodes, aDistrictNames);

khurshid.arshad
Posts: 572
Joined: July 9th, 2012, 11:32 am
Location: Islamabad, Pakistan

Re: Add extra option in array

Post by khurshid.arshad »

Dear Josh and Gregory

I hope both of you are doing fine. I am using this code from an example and i want to add an extra code in the end for "Don't Know" after populating the list from the lookup file. This is very urgent. Please respond at the earliest opportunity.
Regards;
a.

Code: Select all

Preproc

{ use lookup file to load all sectors for district entered }
   LF_DISTRICT_ID = Q_1_2;
   if loadcase(SECTOR_DICT, LF_DISTRICT_ID) = 0 then
      errmsg("Invalid District, please reenter");
      Move to  Q_1_2;
   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(SECTOR_DICT.SECTOR_REC)
      { the arrays that we use for setvalueset start at 0 so we use i-1! }
      aDistrictCodes(i-1) = LF_SEC_ID(i);
      aDistrictNames(i-1) = LF_SEC_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(Q_2_3_4, aDistrictCodes, aDistrictNames);
Saint
Posts: 63
Joined: November 22nd, 2013, 4:59 am

Re: Add extra option in array

Post by Saint »

Hi Arsad,
Try this:

Code: Select all

do varying i = 1 until i >= count(SECTOR_DICT.SECTOR_REC)
      { the arrays that we use for setvalueset start at 0 so we use i-1! }
      aDistrictCodes(i-1) = LF_SEC_ID(i);
      aDistrictNames(i-1) = LF_SEC_NAME(i);
enddo;
aDistrictCodes(i-1) = 999;
aDistrictNames(i-1) = "Don't Know";
aDistrictCodes(i) = notappl;
Hope the variable in question has a length of 3.

Best...
khurshid.arshad
Posts: 572
Joined: July 9th, 2012, 11:32 am
Location: Islamabad, Pakistan

Re: Add extra option in array

Post by khurshid.arshad »

Dear Saint;

Thank yoooou very much.
Regards.
Arshad
Post Reply