The Report Design Document / Expressions in properties |
An Expression is a sequence of operands, operators, and parentheses that the runtime system can evaluate as a single value.
Operator | Description | Example | Precedence |
---|---|---|---|
% |
Arithmetic: Modulus |
x % 2 |
8 |
* |
Multiplication | x * y |
7 |
/ |
Division | x / y |
7 |
+ |
Addition | x + y |
7 |
- |
Subtraction | x - y |
6 |
+ |
Concatenation | string + string |
5 |
< |
Relational/Boolean: Less than |
numeric < 100 |
4 |
<= |
Less then or equal to | numeric <= 100 |
4 |
> |
Greater than | numeric > 100 |
4 |
>= |
Greater than or equal to | numeric >= 100 |
4 |
== |
Equal to | numeric == 100 |
4 |
!= |
Not equal to | numeric <> 100 |
4 |
! |
Logical inverse (NOT) | !(x = y ) |
3 |
&& |
Logical intersection (AND) | expr1 && expr2 |
2 |
|| |
Logical union (OR) | expr1 || expr2 |
1 |
The first column in the table describes the precedence order of the operators, listed highest to lowest. For example, the % modulus operator has a higher precedence than the * operator. Parentheses can be used to overwrite the precedence of operators.
Conditional expressions allow you to express IF/ELSE statements.
Boolean-expression?expression-1:expression-2
The ? operator indicates that this expression is conditional; the return value is dependent on the result of the Boolean expression. If the Boolean expression is TRUE, the first expression is the return value; otherwise, the second expression is the return value.
x<10?Color.RED:null
Operands include:
A literal value for a string in an expression should be delimited by double quotes: "Test".
The data types of 4GL variables are taken into account when constructing expressions. For every 4GL variable an object is created that is either an instance of a FGLNumericVariable or an FGLString Variable. These objects hold the value of the 4GL variable, and at the same time they contain a member variable value which also contains the value. For this reason, it is legal to write "order_line.itemprice" in your expression as a shortcut for "order_line.itemprice.value". Both types of objects have these specific member variables defined:
This conversion table lists 4GL data types and the type into which they are converted within an RTL expression:
4GL type | Corresponding RTL type |
---|---|
CHAR, VARCHAR, STRING and TEXT | FGLStringVariable |
DATE, DATETIME and INTERVAL | FGLNumericVariable |
INTEGER, SMALLINT, FLOAT, SMALLFLOAT, DECIMAL and MONEY | FGLNumericVariable, limited to 15 significant digits. The value of a number larger than 15 digits will be truncated, and the resulting number is rounded. For example, 12345678901234567 will be rounded to 123456789012346. |
For the purpose of these examples, order_line has been replaced with order.
The data item order_line.itemprice is converted to a Numeric type, so we can use the Numeric operators. In order to display the result of a Numeric expression in a WordBox, we must convert the result to a String. See Example 1 in the Using RTL Classes section.
The condition in this Boolean expression tests whether the itemprice is greater than 100; if so, the value returned is 110% of the itemprice; otherwise, the value returned is simply the itemprice.
The property fontItalic is of type boolean, so any RTL expression that we use for that property must return a boolean value (TRUE/FALSE). Any of the relational operators yields a boolean, so the type of the returned value of this expression is a boolean (The expression will return TRUE if the lineitemprice exceeds 20).