The String Class

The String class provides methods for working with text.

Methods

Table 1. Object Methods
Name Description
String  charAt(Numeric index)
Returns the character at the specified index in the current String.
Boolean contains(String s)
Returns TRUE if s is contained within the current String; otherwise FALSE.
Boolean endsWith(String s)
Returns TRUE if the current String ends with s; otherwise FALSE.
Boolean equals(String s)
Returns TRUE if s matches the current String; otherwise FALSE.
Boolean equalsIgnoreCase(String s)
Returns TRUE if s matches the current String, ignoring character case; otherwise FALSE.
String  format(Numeric number, Enum format)
Sets the format of the page number string for a Page Number box.
Numeric indexOf(String s [, Numeric index ])
Returns the index of a substring within the current String.
Boolean isEmpty()
Returns TRUE if the current string has a length of zero (length()=0); otherwise FALSE.
Boolean isNull()
Returns TRUE if the current string has a length of zero (length()=0) and the string is tagged as null; otherwise FALSE. This is the case for null valued input variables read from the input stream.
Numeric lastIndexOf(String s [, Numeric index ])
Returns the index of s within the current String of the last occurrence of s, searching backward.
Numeric length()
Returns the length of the current String
Boolean matches(String s)
Returns TRUE if the current string matches the regular expression s; otherwise FALSE.
String  replace(String old, String new)
Replaces old in the current String with new.
String  replaceAll(String old, String new)
Replaces every occurrence of old in the current String with new.
String  replaceFirst(String old, String new)
Replaces the first occurrence of old in the current String with new.
Boolean startsWith(String s [, Numeric index ])
Returns TRUE if the current String starts with s; otherwise FALSE.
String  subString(Numeric startindex [, Numeric endindex ])
Returns the substring starting at byte position startindex and ending at endindex-1 or the end of the string.
String  toLowerCase()
Converts the current String to lowercase.
String  toString()
Converts the current Numeric value to a String.
String  toUpperCase()
Converts the current String to uppercase.
String  translate()
Uses the current String as the key for a lookup in Genero localization files; returns any entry found, otherwise returns the current String itself.
String  trim()
Removes whitespace characters from the beginning and end of the current String.
String  trimCompress()
Removes whitespace characters from the beginning and end of the current String, as well as any contained whitespace.
String  trimLeft()
Removes whitespace characters from the beginning of the current String.
String  trimRight()
Removes whitespace characters from the end of the current String.
String  urlEncode()
Returns a URL encoding of the current String

Usage

With RTL classes, it is not possible to create and subclass objects. The new keyword is not supported.

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 FGL variable or by calling a method on another object. The object can be a literal value, for example:

"Test".length()

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

Concatenating Strings

Use the + operator to concatenate strings. For example:

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

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

Total: 12.95