Many features and language improvements have been added to CSPro for today's May 1 beta release. As usual, we have also made minor improvements and fixed some bugs. If you experience any bugs while running your applications, in either the Android or Windows environment, please email cspro@lists.census.gov. Here is a summary of the features added since the March beta:
- The .pen application file has been dramatically reduced in size, which makes deploying it to the Android device (and updating it) much quicker. This means that you must recreate all of your .pen files while testing this new version.
- In the last beta release we added a new string type to the CSPro language. Now you can declare traditional alpha variables, as well as these new strings, locally. In the past this was only possible with numeric variables. So now you can write:
PROC FIELD1
alpha (50) localVariable = "This is a locally declared alpha variable.";
errmsg("%s",localVariable);
PROC FIELD2
string localVariable = "This is a locally declared string and is different from the above variable.";
errmsg("%s",localVariable);
- Alpha and string objects can be concatenated using the + operator as an alternative to using the concat function. For example:
string part1 = "Hello", part2 = ", ", part3 = "World!";
errmsg("%s",part1 + part2 + part3); // displays: Hello, World!
- The Android version now respects the upper case attribute. Cases are also marked as partially saved in the case listing. A search button has been added to the show / selcase graphical interface.
- A new "tablet" mode exists on the desktop for CSEntry. With the PFF property FullScreen=NoMenus, not only will the case/file tree on the left be hidden (as occurs with FullScreen=Yes), but the menus and toolbars will also be hidden. This mode is ideal for conducting data entry on tablets.
- A new tool, the PFF Editor, has been added to the suite of CSPro tools. This tool allows you to edit PFFs without needing a text editor. It can be useful as it displays all of the options available to an application developer for a given type of PFF.
- Setvalueset, when provided with array parameters, has always been a way of creating dynamic value sets. Now you can pass one-based arrays to the function, in addition to the traditional zero-based arrays. If the zeroth element is blank, setvalueset will start processing at the first element of the array.
- The accept function now accepts arrays as option parameters, which allows for more dynamic queries. For example:
PROC GLOBAL
array string acceptOptions(20);
// ...
numeric ctr;
do ctr = 1 while ctr <= count(NAME)
acceptOptions(ctr) = "Interview " + NAME(ctr);
enddo;
acceptOptions(ctr) = "All Interviews are Complete";
acceptOptions(ctr + 1) = ""; // mark the end of the array
numeric selection = accept("Select an Option",acceptOptions);
// ...
- There is a new function, showarray, that is similar to the show function, except that instead of displaying items from rosters or records, it displays information located in an array. Here is an example of how it might be used:
PROC GLOBAL
array string showValues(20,3);
// ...
numeric ctr;
do ctr = 1 while ctr <= count(NAME)
showValues(ctr,1) = NAME(ctr);
showValues(ctr,2) = getlabel(SEX,SEX(ctr));
showValues(ctr,3) = maketext("%d-years-old",datediff(AGE(ctr),sysdate("YYYYMMDD"),"y"));
enddo;
showValues(ctr,1) = ""; // mark the end of the array
numeric selection = showarray(showValues,title("Name","Sex","Age"));
// ...
- A set of three new functions has been added: setvalue, getvalue, and getvaluealpha. They can be used as a way of assigning to and retrieving values from dictionary items by using the item name as an alpha field. For example:
Realistically you would not use the function if the variable name that you are assigning to is known. But, for example, if you want to add a button to your userbar that the interviewer can click on to assign missing values to various fields, you could write:
function DoMissing()
setvalue(getsymbol(),missing);
end;
// ...
userbar(add button,"Missing",DoMissing);
Or for a more complicated example, here is code that could be used to write out customized .csv reports based on the parameters specified in an array. By adding, removing, or reordering the strings in the array, you would get a different report without having to touch any other code.
PROC GLOBAL
array string PrintOptions(20) = "NAME","SEX","AGE";
// ...
numeric ctr,recCtr;
for recCtr in PERSON_REC
string output;
do ctr = 1 while PrintOptions(ctr) <> ""
if ctr > 1 then
output = output + ",";
endif;
if getvalue(PrintOptions(ctr)) <> default then // then the field is numeric
output = output + maketext("%f",getvalue(PrintOptions(ctr)));
else
output = output + strip(getvaluealpha(PrintOptions(ctr)));
endif;
enddo;
write("%s",output);
endfor;