Concatenates are streamlined ways of creating references composed of different elements.
setlist: KIDS
1. Child 1
2. Child 2
3. Child 3
1. Please indicate the age of each of your children under the age of 18.
rowsfrom: KIDS
type: integer table
range: 0-17
size: 3
OLDEST. Oldest child
type: radio
selectby: weight
optsfrom: KIDS {weight: $Q1R[id]}
HIGHKIDAGE. Age of oldest child
type: text
invisible: y
cvalue: ${'Q1R'.$QOLDEST}
In the example above, QOLDEST uses a weight
input on the selectby
to determine which one of the three rows has the highest number in it. The answer to QHIGHKIDAGE is then $Q1R combined with the row with highest number (e.g., $Q1R2).
Details
- A period is the concatenation instruction to join the strings.
- Anything within quotes will be rendered as that exact text.
- Anything which is not in quotes will be evaluated to find its value.
- When creating a variable, the information within the squiggly brackets is rendered first.
- When creating a variable, the "$" character is outside of the concatenation syntax.
- You can use this technique in cvalues, option conditioning, group conditioning, set values, etc.
Additional examples
Creating a 'set text' with a concatenate
In the following example, the response option at Q1 is used to drive the set text
used on the following page. This can be useful for times when these texts contain a lot of data, such as HTML display tables.
1. In which of these industries does your company work?
type: radio
1. Farming
2. Social Services
set text: IND1
text: <<END
<table>
<tr class=hdrrow>
<td align=left valign=top>Farming</td>
</tr>
<tr class=tblrow1>
<td align=center>
<li>fact 1</li>
<li>fact 2</li>
</td>
</tr>
</table>
END
set text: IND2
text: <<END
<table>
<tr class=hdrrow>
<td align=left valign=top>Social Services</td>
</tr>
<tr class=tblrow1>
<td align=center>
<li>fact 1</li>
<li>fact 2</li>
</td>
</tr>
</table>
END
new page
[* "__IND" . $Q1 . "__" *]
Concatenate a Variable Name and Response to Set a Value
In the following example, the appropriate row in the Q2 table is set to '10' if there is only one option chosen at Q1. In the "question" line of the set value
widget, the variable name and the single value from the checkbox question are concatenated to define the row.
set list: BEVERAGES
1. Water
2. Milk
3. Soda
4. Sports drinks
5. Alcohol
1. Which of the following do you often drink?
type: checkbox
opts from: BEVERAGES
set value
question: {"Q2R" . $Q1->[0]}
value: 10
condition: countChecked($Q1)==1
2. Of your last 10 beverages, how many were of each type?
type: integer table
showif: countChecked($Q1)>1
show column total: y
size: 3
rows from: BEVERAGES { if anyChecked($Q1,[id]) }
row validation: $Q2RSCT == 10 { message: Please ensure that your total is 10. }
Comments
0 comments
Please sign in to leave a comment.