Index insertions
Index insertions are used to insert the current index value of a loop into the label text. An index insertion is specified by using the @ character, which if specified on its own will refer to the parent loop. However, you can also refer to loops by number, for example, @:1 refers to the parent loop, @:2 refers to the loop above the parent loop (or “grandparent” loop), @:3 refers to the great grandparent loop, and so on. You can also refer to loops by their name, for example, @brand_loop.
If the loop referred to is a categorical loop, the label of the current category in the controlling category list will be inserted in the label. For numeric loops, the current value from the loop's range expression will be inserted in the label.
In the following example of a categorical loop, the label of the current category in the controlling category list will be automatically inserted in the label of the question within the loop and in the label of one of the categories in that question:
Q20 loop
{ SuperFizzy, SweetAndTasty, BubblesGalore }
fields
(
compare_brand "How does {@} compare with the brand you use?"
categorical [1..1]
{
Better "{@} is better",
Same "Both brands are the same",
Worse "My brand is better"
};
) expand;
To present this loop as a series of questions (one for each controlling category) instead of a single grid, you must ask question Q20 using this syntax in the routing section of the interview script:
Q20[..].Ask()
When the script is run, the text for the first question in the loop is “How does SuperFizzy compare with the brand you use?”, the text for the second question is “How does SweetAndTasty compare with the brand you use?”, and so on.
See