ERROR(HOUSE_NUMBER, 17): 'Household_number' is not a declared variable or is a misspelled dictionary entry

Discussions about CSEntry
Forum rules
New release: CSPro 8.0
Post Reply
khurshid.arshad
Posts: 571
Joined: July 9th, 2012, 11:32 am
Location: Islamabad, Pakistan

ERROR(HOUSE_NUMBER, 17): 'Household_number' is not a declared variable or is a misspelled dictionary entry

Post by khurshid.arshad »

Dear CSPro Team;
I am getting the error in “CSPro 7.3.1” on the following logic:

keylist(LISTING_DICT_NSER,caseIdList);
if length(caseIdList)>0 then
do numeric keyCtr = 1 while keyCtr <= length(caseIdList)
numeric household_number = tonumber(caseIdList(keyCtr)[32:3]);
enddo;
LISTING_DICT_NSER.HOUSE_NUMBER=Household_number+1;
else
LISTING_DICT_NSER.HOUSE_NUMBER=1;
endif;


When I declare variable “household_number” outside the loop then it is okay. Otherwise it gives error.
It is working fine in CSPro 7.1.3.

Best.
a.
Gregory Martin
Posts: 1777
Joined: December 5th, 2011, 11:27 pm
Location: Washington, DC

Re: ERROR(HOUSE_NUMBER, 17): 'Household_number' is not a declared variable or is a misspelled dictionary entry

Post by Gregory Martin »

CSPro has the concept of variable scope, so the variable household_number is only accessible within the loop. In the same way, a variable declared in one PROC isn't accessible in another PROC. In CSPro 7.3, we modified the compiler to support dot notation, and as part of that we tightened the scoping rules, so that's why it worked in CSPro 7.1 but not 7.3.
khurshid.arshad
Posts: 571
Joined: July 9th, 2012, 11:32 am
Location: Islamabad, Pakistan

Re: ERROR(HOUSE_NUMBER, 17): 'Household_number' is not a declared variable or is a misspelled dictionary entry

Post by khurshid.arshad »

Thanks. Gregory.

Best.
a.
Post Reply