Using RTL classes

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.

Basic Object Classes

There are object classes for each type of the form item properties. The type of each property is indicated in the Properties page.

Members

Instance Member Methods

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.

Static Member Methods
These methods do not require an object instance. When you invoke the method, it is prefixed with the classname and the '.' character.
Static Member Objects
These objects are member variables that do not require an object instance. The objects are prefixed with the classname and the '.' character. Examples of static member objects are expressions like "Color.RED" or "Numeric.PI".

Examples

  1. This example concatenates the first and last names of a customer, using the trim method of the String class and the + operator:
     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.

  2. Parenthesis can be used to change the order of operations. For example:
    (order_line.unitprice+10).toString()

    Parentheses are used to force the addition to be done prior to the conversion to a String.

  3. This conditional expression used in the color property of the order_line.unitprice WordBox will change the color to red if the value is less than 20:
     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.

  4. It is legal to call methods on the return value of a method. For example, this is a valid expression:

    This figure shows a valid expression example as described in this topic.

    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.