Dynamic valueset stopped working in 7.2.0

Discussions about CSEntry
Forum rules
New release: CSPro 8.0
Post Reply
Don
Posts: 55
Joined: February 15th, 2013, 1:28 pm
Location: Barbados

Dynamic valueset stopped working in 7.2.0

Post by Don »

I had created a dynamic valueset in my menu program that allows someone to choose a household to interview. It displays information correctly but the CHOOSE_HOUSEHOLD variable does not include leading spaces. If " 52922022102 (note the leading space) is passed to the variable, it seems to store it as "52922021201 ".

Code: Select all

//Launches the Questionnaire
function LaunchQuestionnaire()

	string pffFilename = Pathname(application) + "../Questionnaire/Labourforce.pff";
	setfile(pffFile,pffFilename,create);

	filewrite(pffFile,"[Run Information]");
	filewrite(pffFile,"Version=CSPro 7.1");
	filewrite(pffFile,"AppType=Entry");
	filewrite(pffFile,"Description=Continuous Labourforce Sample Survey");

	filewrite(pffFile,"[DataEntryInit]");
	filewrite(pffFile,"OperatorID=%s",UNAME);
	filewrite(pffFile,"StartMode=Add;%s",CHOOSE_HOUSEHOLD);
	filewrite(pffFile,"ShowInApplicationListing=Hidden");
	filewrite(pffFile,"AutoAdd=No");
	filewrite(pffFile,"Lock=CaseListing");

	filewrite(pffFile,"[Files]");
	filewrite(pffFile,"Application=%s","./Labourforce.ent");
	filewrite(pffFile,"InputData=%s","../Data/data.csdb|CSPRODB");
	filewrite(pffFile,"Paradata=%s","../Data/Labourforce.cslog");
	
	filewrite(pffFile,"[ExternalFiles]");
	filewrite(pffFile,"LISTING_DICT=%s","../Data/Controlsheet.csdb|CSPRODB");
	filewrite(pffFile,"ENUMERATIONREPORT_DICT=%s","../Data/enumrpt.csdb|CSPRODB");
	
	filewrite(pffFile,"[UserFiles]");
	filewrite(pffFile,"PFFFILE=%s","");

	filewrite(pffFile,"[Parameters]");
	filewrite(pffFile,"OnExit=../Menu/Menu.pff");
	
	filewrite(pffFile,"RNDNO=%s",CHOOSE_HOUSEHOLD[1:2]);
	filewrite(pffFile,"EDNO=%s",CHOOSE_HOUSEHOLD[3:3]);
	filewrite(pffFile,"PARNO=%s",CHOOSE_HOUSEHOLD[6:3]);
	filewrite(pffFile,"STRATUM=%s",CHOOSE_HOUSEHOLD[9:1]);		//skip Building no (CHOOSE_HOUSEHOLD[10:3]) which is not included in Labourforce ID items
	filewrite(pffFile,"HHNO=%s",CHOOSE_HOUSEHOLD[10:3]);		
	filewrite(pffFile,"ENMRTR=%s",maketext("%v",visualvalue(USERID)));
	filewrite(pffFile,"ADDRESS=%s",address(searchArray(address,CHOOSE_HOUSEHOLD),2));
	filewrite(pffFile,"BLDGNO=%s",address(searchArray(address,CHOOSE_HOUSEHOLD),3));
	
	close(pffFile);

	execpff(filename(pffFile), stop);

end;

PROC CHOOSE_HOUSEHOLD
//create a dynamic valueset to choose a household for interview
onfocus
	numeric nextEntry = 1;
	forcase LISTING_DICT where LSTED = ME_ED and LSTROUND = ME_ROUND do
		vscode(nextEntry) = maketext("%v%v%v%v%v",LSTROUND,LSTED,LSTPARISH,LSTSTRATUM,LSTSAMPLE);
		vsLabel(nextEntry) = maketext("%03d-%03d-%03d: %V (%v)",LSTED,LSTBUILDING,LSTSAMPLE,strip(LSTLNAME),strip(LSTREMARKS));
		address(nextEntry,1) = vscode(nextEntry);
		address(nextEntry,2) = LSTADDRESS;
		address(nextEntry,3) = maketext("%V",LSTBUILDING);
		inc(nextEntry);
	endfor;
	
	vsCode(nextEntry) = "";
	
	setvalueset($, vsCode, vsLabel);
	
	if vscode(1) = "" then		//if nothing is in the valueset
		errmsg("There are no questionnaires available for this ED (ED%d). Please fill out a control sheet first",ME_ED);
		if LOGIN = 1 then 
			move to INTERVIEWER_MENU;
		elseif LOGIN = 2 then
			move to SUPERVISOR_MENU;
		endif;
	endif;

postproc
	errmsg("|%v-%v-%v-%v-%v|",LSTROUND,LSTED,LSTPARISH,LSTSTRATUM,LSTSAMPLE);
	errmsg("|%v|",CHOOSE_HOUSEHOLD);
	errmsg("RNDNO=%v",CHOOSE_HOUSEHOLD[1:2]);
	errmsg("EDNO=%s",CHOOSE_HOUSEHOLD[3:3]);
	errmsg("PARNO=%s",CHOOSE_HOUSEHOLD[6:3]);
	errmsg("STRATUM=%s",CHOOSE_HOUSEHOLD[9:1]);		
	errmsg("HHNO=%s",CHOOSE_HOUSEHOLD[10:3]);	
	launchQuestionnaire();
	if LOGIN = 1 then 
		move to INTERVIEWER_MENU;
	elseif LOGIN = 2 then
		move to SUPERVISOR_MENU;
	endif;
I use substring expressions to pass this information to the pff file, so using my previous example, the following values get passed:
RNDNO = "52"
EDNO = "922"
PARNO = "021"
STRATUM = "1"
HHNO = "02 "

The values that should be passed are
RNDNO = " 5"
EDNO = "292"
PARNO = "202"
STRATUM = "1"
HHNO = "102"

This results in an out of range error for RNDNO and CSEntry crashes. Is there a way to correctly force the leading space
Don
Posts: 55
Joined: February 15th, 2013, 1:28 pm
Location: Barbados

Re: Dynamic valueset stopped working in 7.2.0

Post by Don »

I made a workaround by adding the following line in the postproc of CHOOSE_HOUSEHOLD

Code: Select all

CHOOSE_HOUSEHOLD = maketext("%13.12s",CHOOSE_HOUSEHOLD);
Which makes me think that this is a bug since using %13s alone does not work. If there's anything that I could have missed. please let me know.
aaronw
Posts: 561
Joined: June 9th, 2016, 9:38 am
Location: Washington, DC

Re: Dynamic valueset stopped working in 7.2.0

Post by aaronw »

When I manipulate a dictionary alpha I don't have issues with a leading space.
leading-space.PNG
leading-space.PNG (4.38 KiB) Viewed 2303 times
However, I do wonder if this has to do with passing the value through a PFF to another application. Sysparm will left justify (trim) a string.
http://www.csprousers.org/help/CSPro/sy ... ction.html

If this doesn't answer your question send your application to cspro@lists.census.gov with a comment where the leading space is trimmed.
Post Reply