Desktop User Guides > Professional > Interview scripting > Writing interview scripts > Logical expressions
 
Logical expressions
One of the main things you will want to do in the Routing section is check how a respondent has answered a question. You do this by writing an expression that compares the current response against a given value or set of values and returns True or False depending on the results of the comparison. A very simple example is an expression that tests whether the respondent is female. If the question is called Gender, the expression:
Gender = {Female}
returns True if the answer to Gender to Female and False if it is anything else.
Another simple example is a test for age. If Age is a numeric question, the expression:
Age >= 60
returns True for anyone who is aged 60 or older.
The Interview Scripting Language provides a number of keywords and operators for testing responses, some of which work with all question types and others of which are specific to a particular type of question.
Expressions need not be limited to using question names and fixed values. You can replace the question name or the value, or both, with expressions. A simple example is one that subtracts the respondent’s age from the statutory retirement age (assume it is 65 years old) and then tests whether the respondent has more than ten years left to work:
(65 - age) > 10
The Interview Scripting Language recognizes the standard arithmetic operators +, −, * (multiply), and / (divide). Normally, you use these operators with numeric questions and numeric values, but they can also be used in more advanced expressions to manipulate and test categorical or text questions.For more information, see Arithmetic operators.
This section explains:
Checking numeric responses
Checking categorical responses
Checking for special responses to non-categorical questions
Checking text responses
Checking date/time responses
Combining expressions
Reversing the meaning of an expression
See also
Writing interview scripts