In this article
When making conditions, the following standard Jscript logical operators are useful:
Description | Symbol |
Logical NOT | ! |
Less than | < |
Greater than | > |
Less than or equal to | <= |
Greater than or equal to | >= |
Equal to | == |
Not equal to | != |
Logical AND | && |
Logical OR | || |
inc condition
f("qID") of multi question returns a set of the codes answered to question qID. If you want to test for a particular value, use .inc (includes). f("qID").inc("code") will return TRUE if "code" is one of the answers to qID.
any condition
If you want to test for any of a particular set of values, use .any.
f("qID").any("code1","code2","code3") will return TRUE if "code1", "code2" or "code2" are answered in qID.
all condition
If you want to test whether all of a set of values are answered, use .all.
f("qID").all("code1","code2","code3") will return TRUE if "code1", "code2" and "code3" all are answered in qID.
none condition
If you want to test whether none of a set of values are answered, use .none.
f("qID").none("code1","code2","code3") will return TRUE if neither "code1", "code2" nor "code3" are answered in qID
between condition
If you want to test whether a numeric response is within a particular range, use between.
f("qID").between(3,5) will return TRUE if the answer to the numeric question qid is greater than or equal to 3 and less than or equal to 5.
size condition
If you need a test on how many answers were selected on a multi question, you may use .size(). f("qID").size() returns the number of answers to the question qID. f("qID").size() > 1 will return TRUE if qID has more than one answer.
toNumber condition
The .toNumber() method converts the variable to a number.
Example:
The "codes", i.e. the answers to questions, are always stored as strings and not numbers. This means that the f function always returns strings or sets of strings. You must therefore be careful when using the greater than (>) or less than (<) operators. If you consider how you sort items alphabetically (as in a dictionary), a sequence of numbers 1,2,3,…,10,11 will be sorted to: 1,10,11,2,3,…,9 when sorted as strings. So f('q1')<'3' will be TRUE for the numbers 1,10,11 and 2, and that was probably not your intention. You must therefore force the codes to numbers before running a condition with greater than or less than, using .toNumber() like this: f("q1").toNumber()<3. Using this, the expression will be true for 1 and 2, as expected.