Fills are used to customize
question text based on respondents' specific characteristics. This is done by embedding CSPro logic into the text as a
template expression and surrounding it with one of the supported delimiters: ~~, ~~~, and
<? ?>.
Fills may contain any valid CSPro logic expression that evaluates to a string or numeric value, or
binary data. Logic expressions may include dictionary items, variables, occurrence labels, user-defined functions, as well as any built-in CSPro functions and operators.
Enter some question text that needs to be customized. For words or phrases that need to be filled, enter a dictionary item or variable with ~~ characters before and after. For example:
Can I speak with <b>~~FIRST_NAME~~</b> now?
When the entry system comes to this text, it will insert the person's FIRST_NAME value into the question text:
Can I speak with <b>Marjorie</b> now?
Can I speak with <b>Allyson</b> now?
When used with numeric values, the fill uses the value code. For example,
~~SEX~~ might be 1 or 2. If you want to use the value label, you can use the
getvaluelabel function:
How old was <b>~~FIRST_NAME~~</b> when they completed <b>~~getvaluelabel(HIGHEST_GRADE_COMPLETED)~~</b>?
You can customize the question text by inserting an item or group's
occurrence labels into the text. For example:
How much did you spend on <b>~~getocclabel()~~</b> in the last month?
You can insert the return value of a
user-defined function into the question text. The function can return either numeric or string values. For example:
Thinking now about <b>~~FIRST_NAME~~</b>, what is <b>~~SexPronoun()~~</b> age?
In logic, a user-defined function must be declared, as in:
You can use HTML tags in order to dynamically format fills using logic. If you use HTML tags, you must surround the fill with three tildes (~~~) instead of two. This tells CSPro not to escape the tags when substituting the fill value. If you use the standard two tildes ~~, the literal HTML will substituted instead of the formatted value.
For example the question text:
You have entered the following household members:
~~~householdMembers~~~
with the following logic:
householdMembers = "<ul><li>Bouba</li><li>Frank</li><li>Chen</li></ul>";
will result in:
You have entered the following household members:
Or more realistically: