Select Case
Select Case is a quick and easy way of defining conditional actions when the conditions are based on a question that can have only one value; that is a single-response categorical question, a numeric question, or a boolean question.
Syntax
Select Case <question_name>.Response.Value
Case <response_1>
<actions_1>
Case <response_2>
<actions_1>
...
[Case Else
<actions_n>]
End Select
Parameters
<question_name>
The name of the question whose response controls the conditional actions.
<response_1> and <response_2>
Responses to the question or, for numeric responses, expressions that group responses to the question.
<actions_1> and <actions_2>
Are one or more statements to be executed if the question’s response matches the response for the current Case statement.
<actions_n>
One or more statements to be executed for respondents who fail all the previous Case tests.
Example
Suppose your interview script contains the following questions:
BestColor "Which color scheme do you think suited
the product best?" categorical [1..1]
{
BluePink "Blue and pink" ,
RedYellow "Red and yellow" ,
YellowGreen "Yellow and green" ,
None "None were suitable"
};
Red "Why do you think red and yellow is effective?" text [1..];
Blue "Why do you think blue and pink is effective?" text [1..];
Green "Why do you think yellow and green is effective?"
text [1..];
Having asked the
Color question, you want to know why the respondent chose a particular color scheme. Because the question allows one response only, a
Select Case statement makes this easy (compare this example with the one that uses
If and
ElseIf in
If...Then...Else):
BestColor.Ask()
Select Case BestColor.Response.Value
Case {RedYellow}
Red.Ask()
Case{BluePink}
Blue.Ask()
Case {YellowGreen}
Green.Ask()
End Select
The Select Case statement tells the interviewing program to check which color was chosen. The Case statements define the possible responses and the actions that are to be taken for each one. Once a respondent has satisfied a Case test and the actions for that test have been executed, all other Case tests are ignored and the respondent continues with the next statement after End Select. Respondents who do not satisfy any of the Case tests simply pass through this section of the routing script with no actions being taken. In the example, this is what happens for respondents who say that none of the color schemes was suitable.
Here is an example for a numeric question.
Age.Ask()
Select Case Age
Case < 30
Young.Ask()
Case 30 To 59
Middleaged.Ask()
Case Else
Old.Ask()
End Select
See also