The String Class
The String class provides methods for working with text.
Syntax
String
Methods
Name | Description |
---|---|
|
Returns a String containing the character at the specified index in the current String. |
|
Returns a Boolean value (TRUE/FALSE) specifying whether s is contained within the current String. |
|
Returns a Boolean value (TRUE/FALSE) specifying whether the current String ends with s. |
|
Returns a Boolean value (TRUE/FALSE) specifying whether s matches the current String. If one of the Strings is null the method returns FALSE. |
|
Returns a Boolean value (TRUE/FALSE) specifying whether s matches the current String, ignoring character case. If one of the Strings is null the method returns FALSE. |
|
Sets the format of the page number string for a PAGENOBOX. The value for format can be: ARABIC, LOWERROMAN, UPPERROMAN |
|
Returns a Numeric value representing the index of s within the current String. |
|
Returns a Numeric value representing the index of s within the current String, starting from byte position index. Returns zero if the substring was not found. Returns -1 if the current String is null. |
|
Returns a Boolean value. Returns true if the current string has a length of zero
(length()=0 ), otherwise false. |
|
Returns a Boolean value. 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.For backward compatibility, null values do not have special behavior when used with the various operators. Specifically an input variable of type string that is null behaves like the empty string. |
|
Returns a Numeric value representing the index within the current String of the last occurrence of s, searching backward. |
|
Returns a Numeric value representing the index within the current String of the last occurrence of s, searching backward. starting at the specified position index. |
|
Returns a Numeric value representing the length of the current String. |
|
Returns a Boolean value specifying whether the current String matches the regular expressions. |
|
Replaces old in the current String with new. |
|
Replaces every occurrence of old in the current String with new. |
|
Replaces every occurrence of old in the current String with new. |
|
Returns a Boolean value specifying whether the current String begins with s. |
|
Returns a Boolean value specifying whether the substring in the current String beginning at the position index contains s. The first byte of a string is at position 0. |
|
Returns the substring starting at byte position sindex and ending at the character at eindex-1. The first byte of a string is at position 0. |
|
Returns the substring starting at the position index in the current String. The first byte of a string is at position 0. |
|
Converts the current String to lowercase. |
|
Converts the current Numeric value to a String. |
|
Converts the current String to uppercase. |
|
Uses the current String as the key for a lookup in Genero localization files; returns any entry found, otherwise returns the current String itself. |
|
Removes white space characters from the beginning and end of the current String. |
|
Removes white space characters at the beginning and end of the current String, as well as any contained white space. |
|
Removes white space characters from the beginning of the current String. |
|
Removes white space characters from the end of the current String. |
|
Returns a URL encoding of the current String. |
Usage and Examples
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 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. For example:
("Total:"+" "+order_line.totalorderprice).toString()
This expression returns the current value of totalorderprice
as part of a String
value:
Total: 12.95