Understanding expressions
An expression is usually a combination of data elements (called operands) and operators that produces a resulting value. The result of an expression is considered to be either alpha, numeric, or object.
The simplest form of an expression is a single alpha or numeric variable, literal, object handle, or function/method reference without any operators.
A method used in a simple expression must return a type other than VOID; otherwise, a “No operator void” error ($ERR_NOOPER) will result. |
You can build more complex expressions by combining operators with operands.
Truth values
The truth value of an expression is based on its result as follows:
- The truth value of an alpha expression is false if its length is zero (“”) or contains only ASCII space characters, and true in all other cases (including if it only contains ASCII zero characters).
- The truth value of a numeric expression is false if it is zero, and true if it is nonzero.
- The truth value of an object result is the truth value of the result returned from the op_True method declared by the class of the object. If the op_True method is not declared by the class, a “No operator op_True()” error ($ERR_NOOPER) is generated.
-
IF (nullable) is true when the result is not ^NULL or 0, and IF (!nullable) is true when the result is ^NULL or 0.
A System.String object is always converted to alpha before its truth value is evaluated. |