The Report Design Document / Expressions in properties |
RTL expressions do not contain the primitive data types "byte", "short", "int", "long", "float", "double", "boolean" and "char". Instead, everything is expressed as objects. All methods are member functions. There are no global functions.
There are object classes for each type of the form item properties. The type of each property is indicated in the Properties page.
These methods are called on an object instance. You can get an object instance by referencing a 4GL variable or by calling a method on another object. You can also use a literal value as an object instance.
When you invoke the method, it is prefixed with the object instance name and the "." character.
Examples of instance methods are expressions like "order_line.customer_name.trim()". This is valid because the 4GL variable order_line.customer_name has a CHAR data type, which is converted within the RTL Expression to an object of the type String. And, the method trim is a member function of a String object.
Methods always yield objects, so it is also legal to call methods on the return value of a method.
order_line.shipfirstname.trim()+" "+order_line.shiplastname.trim()
This expression prints the first name (trimmed of trailing blanks), a string consisting of a single space, and the last name (trimmed). Use double quotes instead of single quotes to delimit strings.
(order_line.unitprice+10).toString()
Parentheses are used to force the addition to be done prior to the conversion to a String.
order_line.unitprice<20?Color.RED:Color.BLACK
This expression specifies that the return value when the boolean expression is TRUE is the static member variable RED of the Color class, otherwise the return value is the static member variable BLACK.
Figure 1. order_line.customer_name.trim().toUpperCas().substring(1)
In this example, the object order_line.customer_name is a BDL CHAR variable; CHARs are assigned to the String type. The String method trim() is called first, returning the String object a. The method toUpperCase() is called for the object a, returning object b which will be in upper case. Finally, the method substring() is called for the object b, returning object c. If the customer_name is "Springs", the resulting object c is the string "PRINGS".
There are many additional examples of expressions in the properties of report elements defined in the 4rp programs that are part of the GRWDemo project.