Study Definition module

 

Operators

Arithmetic operators

The arithmetic operators are applied in the order presented below. You may use parentheses to override these default priorities.

 

For example, 3*4+5 is calculated as ( 3 x 4 ) = 12;  then 5 is added to the total, giving a result of 17.

However, in the expression 3*(4+5), the sum in parentheses is calculated first; ( 4 + 5 ) = 9; then the total is multiplied 3, giving a result of 27.

Name

Symbol

Format

Description

Exponentiation

^

Number^exponent, e.g. 5^3

Five to the power of three (5³), where 3 is the exponent number, giving the result 125

Multiplication

*

Number1*number2, e.g. 5*3

Five times three

Division

/

Number1/number2, e.g.15/3

Fifteen divided by three

Addition

+

Number1+number2, e.g. 10+5

Ten plus five

Subtraction

-

Number1-number, e.g. 20-5

Twenty minus five

See also Arithmetic Functions.

Comparison operators

Name

Symbol

Format

Description

Equal to

=

Expr1 = Expr2

Condition true if Expr1 equal to Expr2

Case sensitive text comparison

==

Text1 == Text2

Condition true if Text1 is identical to Text2 (can only be used for text expressions)

Less than

<

Expr1 < Expr2

Condition true if numeric Expr1 less than numeric Expr2

Less than or equal to

=<

Expr1 =< Expr2

Condition true if numeric Expr1 less than or equal to numeric Expr2

Greater than

>

 Expr1 > Expr2

Condition true if numeric Expr1 greater than numeric Expr2

Greater than or equal to

>=

Expr1 >= Expr2

Condition true if numeric Expr1 equal to or greater than numeric Expr2

Not equal to

<>

Expr1 <> Expr2

Condition true if Expr1 not equal to Expr2

Text comparison

like

Text1 like Text2

Condition true if Text1 matches Text2. Text may contain wildcard symbols. The following condition is true if s1 is any 3-character string, e.g. 's1' like '???'

Matching is case-insensitive.

Numerical range comparison

between

Expr between (Expr1,Expr2)

Condition is true if Expr is greater than or equal to Expr1 and less than or equal to Expr2

e.g. age between (18,60)

Wildcard symbols

The following symbols may be used with the like operator.

Symbol

Description

%

Represents any number of characters (including none) in a term for a match to be found.  For example th%e will match 'the', 'thee', 'three', 'thylacine' and all terms starting with 'th' and finishing with 'e', with or without characters between 'a' and 'e'.

?

Represents exactly one character in a term for a match to be found, e.g. ab?de will match 'abide', 'abode' and all terms starting with 'ab' and finishing with 'de', with any single character between.

Text concatenation operators

Symbol

Format

Description

&

Text1 & Text2

Evaluates to the text formed by joining together the terms Text1 and Text2. Useful for creating messages containing free text with embedded question values.

 

When using the & operator to concatenate strings, if any of the referenced data is unknown, the entire expression remains blank. You can use "isknown" to ensure that default values are used. See example

Logical operators

Function

Format

Description

not

not Cond1

Condition is true if Cond1 is false

and

Cond1 and Cond2

Condition is true if both Cond1 and Cond2 are true

or

Cond1 or Cond2

Condition is true if either Cond1 or Cond2 (or both) are true

 

When using not it is advisable to also use the general function isknown to avoid unexpected results concerning unknown data.

 

For example, the condition 'not q1 = 8' evaluates to true if q1 has a value that is not 8, but it also evaluates to true when q1 does not have a value as a result of not having been filled in.

If you use isknown as well as not you could create the condition 'isknown(q1) and not q1 = 8'

This evaluates to false when q1 has not been filled in, avoiding confusion.

 

Note that the condition 'isknown(q1) and not q1 = 8' is equivalent to 'q1 <> 8'

This is because <> is treated as a single operator, whereas "not q1 = 8" the "not" is applied after the "=" has been evaluated.

 

 

Related Topics