CSPro Syntax Wall Cards

CSPro Syntax Wall Cards
comments
// Rest of line comment
{Multi-line
comment}
if then else
if AGE < 5 then
errmsg(“Under 5”);
else
errmsg(“5 OR OVER”);
endif;
comparison
= Equal
<> Not equal
< Less than
> Greater than
<= Less than or equal
>= Greater than or equal
in In range (AGE in 10:15)
errmsg
errmsg(“Hello”);
errmsg(“Age is %d”, AGE);
errmsg(“Name is %s”, NAME);
%d Display number as integer
%f Display number with decimal
%s Display text string
reenter
reenter;
reenter AGE;
logical operators
and (both true)
or (either true)
not (not true->false,
not false->true)
Arithmetic
+
*
/
%
^
Addition
Subtraction
Multiplication
Division
Remainder
Exponentiation
strip
s = strip(NAME);
getlabel
s = getlabel(SEX_VS1,
SEX);
s = getlabel(SEX_VS1,
1);
errmsg with select
errmsg(“Mother too young”)
select(“Fix age”, AGE,
“Fix relationship”,
RELATIONSHIP);
sysdate
d = sysdate(“YYYYMMDD”);
systime
t = systime();
noinput
noinput;
demode
m = demode();
skip
skip to AGE;
skip to next AGE;
skip to next;
endgroup
endgroup;
endlevel
endlevel;
Special Values
notappl (blank/skipped)
missing (9, 99, 999…)
default (read error)
Subscripts
SEX(1)
AGE(3)
SEX(CHILD_MOTHER)
totocc
totocc(ADULTS000);
curocc
curocc();
curocc(ADULTS000);
variables
numeric numberOfKids;
alpha[30] nameOfMother;
string nameOfMother;
do loop
do i=1 while i < 10
if AGE(i) < 5 then
under5s = under5s + 1;
endif;
enddo;
count
numAdults = count(ADULTS);
under5s = count(ADULTS where
AGE < 5);
seek
indexHead =
seek(RELATIONSHIP = 1);
pos
p = pos(“A”,
“APPLE”);
setvalueset
setvalueset(RELATIONSHIP,
RELATIONSHIP_MALE);
setvalueset(RELATIONSHIP,
codes,
labels);
datediff
dd = datediff(DATE_OF_BIRTH,
DATE_OF_INTERVIEW);
field notes
text = editnote();
text = getnote();
putnote(text);
prompt
text = prompt(“What’s your name”);
text = prompt(“Source of water?”,
“river”);
loadcase
found = loadcase(VILLAGE_DICT,
PROV, DIST);
user functions
function isUnder5(index)
isUnder5 = AGE(index) < 5;
end;
userbar
userbar(clear);
userbar(show);
id = userbar(add button, “Go”, go);
userbar(remove, id);
accept
choice = accept(“Finished?”,
“Yes”, “No”);
advance
advance to AGE;
move
move to AGE;
move to AGE advance;
showarray
string peopleArray(30, 3);
showarray(peopleArray,
title(“Name”, “Age”, “Sex”));
visualvalue
a = visualvalue(AGE);
execsystem (Windows)
execsystem(“calc.exe”);
execsystem(
“explorer.exe myreport.html”,
maximized, wait);
execsystem (Android)
execsystem(
“app:com.google.android.gm”);
execsystem(
“view:myphoto.jpg”);
execsystem(
“camera:myphoto.jpg”);
maketext
msg = maketext(
“%s is %d years old”,
NAME, AGE);
getos
if getos() in 20:29 then
errmsg(“Android”);
endif;
if getos() in 10:19 then
errmsg(“Windows”);
endif;
gps
gps(open);
gps(read, 60, 10);
gps(latitude);
gps(longitude);
fileexist
if fileexist(“myfile.dat”) then
…
endif;
filedelete
filedelete(“myfile.dat”);
setfile
file tempfile;
setfile(tempfile, “myfile.dat”);
filewrite
file tempfile;
filewrite(tempfile, “hello”);
filewrite(tempfile,
“hello %s”,
NAME);
close
close(tempfile);
execpff
execpff(“myapp.ent”,
wait);
execpff(“myapp.ent”,
stop);
stop
stop(0); // back to case list
stop(1); // back to app list
length
n = length(NAME);
sysparm
value = sysparm(“KEY”);
tonumber
n = tonumber(“12.5”);
syncconnect
synconnect( web,
“https://www.server.com”,
”user”, “password”);
synconnect(Bluetooth);
syncdata
syncdata(PUT, MYDICT);
syncfile
syncfile(PUT,
“/localpath/file.txt”,
“serverpath/”);
syncfile(GET,
“/serverpath/file.txt”,
“serverpath/”);
syncdisconnect
syncdisconnect();
syncserver()
syncserver(“/path/to/root”);
setcaselabel
setcaselabel(MYDICT,
“my case label”);
getocclabel
getocclabel(PERSON(i));
setocclabel
setocclabel(PERSON(i),
NAME(i));
savesetting
savesetting(“InterviewerName”,
INTERVIEWER_NAME));
loadsetting
string name = loadsetting(
“InterviewerName”);
locate
locate(MY_DICT,>=,"");
pathname
s = pathname(Application);
s = pathname(Temp);
s = pathname(CSEntry);