Operators and Precedence

Expressions are evaluated according to operator precedence. Operators of higher precedence—1 being the highest—are evaluated first. Operators of the same level are evaluated from left to right. Precedence may be overridden using parentheses, which can be nested. The inner most parenthesis is evaluated first. Operators, types, and precedence are described in the following table.

Operator Type Precedence Description
* NUMERIC 1 Multiplication
/ NUMERIC 1 Division
Mod NUMERIC 1 Modulo division
+ NUMERIC 2 Addition
- NUMERIC 2 Subtraction
& STRING 2 Concatenation
< BOOLEAN 3 Less than
<= BOOLEAN 3 Less than or equal to
> BOOLEAN 3 Greater than
>= BOOLEAN 3 Greater than or equal to
= BOOLEAN 3 Equal to
<> BOOLEAN 6 Not equal to
And BOOLEAN 4 Logical AND
Or BOOLEAN 4 Logical OR
Not BOOLEAN 5 Logical NOT

Unlike VBScript, all expressions within a Mobile Channels statement are always evaluated. The following code example shows if arr.count is not greater than zero, arr(1) and arr(2) are evaluated and the references to arr(j) result in error.

If arr.count > 0 and arr(1) = "test1" then 
   arr(2) = "test2" 
End If

If arr.count > 0 is FALSE, the ensuing expressions are invalid. The following code example shows the correct implementation of logical operators.

If arr.count > 0 then
   If arr(1) = "test3" then 
      arr(2) = "test4"
   End If
End If