A combination of one or more terms and operators that evaluate to a single value of a specific data type.
Note that each term of the expression can itself be formed from an expression, resulting in multiple possible combinations of basic terms and operators, with or without grouping parentheses. Note that each of these elements, except for a more complex Expression, represents a basic term of the expression.
For information on the precedence of operator evaluation, see Table 1.
The procedure, r-expression.p, evaluates an expression to identify the value of an element in an ABL single-dimensional array (iArray) that is specified using two-dimensional coordinates (iDim1 and iDim2):
r-expression.p
DEFINE VARIABLE iDim1 AS INTEGER NO-UNDO. DEFINE VARIABLE iDim2 AS INTEGER NO-UNDO. DEFINE VARIABLE iDim1Extent AS INTEGER NO-UNDO INITIAL 3. DEFINE VARIABLE iDim2Extent AS INTEGER NO-UNDO INITIAL 5. DEFINE VARIABLE iArray AS CHARACTER NO-UNDO EXTENT 15 INITIAL ["A","B","C","D","E", /* iDim1 = 1 */ "F","G","H","I","J", /* iDim1 = 2 */ "K","L","M","N","O"]. /* iDim1 = 3 */ DO iDim1 = 1 TO iDim1Extent: DO iDim2 = 1 TO iDim2Extent: MESSAGE "iArray[" iDim1 "," iDim2 "]" " = " iArray[ iDim2 + (iDim1 - 1) * iDim2Extent ] VIEW-AS ALERT-BOX. END. END. |
This procedure contains several expressions in the DO statements as well as in the MESSAGE statement. The expression that evaluates the index on the term, iArray, using a two-dimensional coordinate is shown in bold. This expression first evaluates the subtraction (-) operation in parentheses, then, in order by operator precedence, evaluates the multiplication (*) operation followed by the addition operation (+).
Precedence (highest to lowest) | Operator function | Symbol |
---|---|---|
11 | Numeric negative (unary) Numeric positive (unary) |
- + |
10 | Numeric modulo Numeric division Numeric multiplication |
MODULO / * |
9 | Date subtraction Datetime subtraction Numeric subtraction Date addition Datetime addition Numeric addition String concatenation |
- - - + + + + |
8 | Relational string match Relational less than Relational less than or equal to Relational greater than Relational greater than or equal to Relational equal to Relational not equal to Relational string beginning |
MATCHES LT or < LE or <= GT or > GE or >= EQ or = NE or <> BEGINS |
7 | Bitwise NOT (unary) | NOT |
6 | Logical NOT (unary) | NOT |
5 | Bitwise AND | AND |
4 | Bitwise XOR | XOR |
3 | Bitwise OR (inclusive) | OR |
2 | Logical AND | AND |
1 | Logical OR (inclusive) | OR |
Note that before the ABL Virtual Machine (AVM) applies the operators to an expression, it evaluates all the basic terms (variables, properties, methods, functions, etc.) of the expression individually from left to right.