String Class Usage and Examples

Like all RTL Classes, the "new" keyword is not supported, so that it is not possible to create and subclass objects.

All literal String values in an expression must be delimited by double quotes.

All the methods require an object instance. When you invoke the method, it is prefixed with the object instance name and the "." character. You can get an object instance by referencing a 4GL variable or by calling a method on another object. The object can be a literal value, for example:

"Test".length()

Numeric data items in WordBoxes and WordWrapBoxes

If you enter an expression for the text property of a WordBox or WordWrapBox, the value must be a String. You can use the toString() function in your expressions to convert numbers to Strings. When you drag a Numeric data item onto the Report Design Window, it is automatically placed in a WordBox element, and an expression for the text property is created to convert it to a String.

For example:

order_line.unitprice.toString()

The indexes of a String (example subString)

When specifying the character position (index) of a string, the first character value is at position 0.

For example, when using the subString function, the substring begins at the specified startindex and ends at the character at endindex -1. The length of the string is endIndex minus startIndex:

order_line.billState.subString(1,5) 

If the value of the String billState is "smiles" (indexes 012345), the substring returned is "mile", and the length of the string is 5 minus 1 = 4.

Concatenating Strings

Use the + operator to concatenate strings.

Example:

("Total:"+" "+order_line.totalorderprice).toString()

This expression returns the current value of totalorderprice as part of a String value:

"Total: 12.95"