Text expressions
A text expression resolves to a series of characters, and you specify such an expression in various situations; for example, on the right side of an assignment statement. The text expression may be any of these:
- An item (or system variable) that contains a series of characters.
- A character literal, which is a series of characters delimited by double quote marks. Such a literal may include single-byte characters, double-byte characters, or a combination of the two.
- A substring of a literal or item that contains a series of characters. For details, see Substrings.
- The invocation of any string-formatting system word that returns a series of characters. For details, see String formatting (system words).
- A series of values of the previous kinds, where each value is separated from the next by the concatenation operator, which is a plus sign (+). The following statement assigns WebSphere to myString:
myString = "Web" + "Sphere";- Any other function invocation that returns a series of characters. In this case, you cannot use the concatenation operator.
Although an item or return value can contain Unicode characters, a literal cannot.
Any character preceded with the escape character (\) is included in the text expression. In particular, you can use the escape character to include the following characters in a literal, item, or return value:
- A double quote mark (")
- A backslash (\)
- A backspace, as indicated by \b
- A form feed, as indicated by \f
- A newline character, as indicated by \n
- A carriage return, as indicated by \r
- A tab, as indicated by \t
Examples are as follows:
myString = "He said, \"Escape while you can!\""; myString2 = "Is a backslash (\\) needed?";An error occurs if a literal has no ending quote mark:
myString3 = "Escape is impossible\";Each value in the text expression must be valid for the context in which the expression is used. For example, an item of type UNICODE cannot be used in an expression assigned to an item of type CHAR. Additional details are in Assignments.
Related reference
Assignments
Datetime expressions
Expressions
Items
Logical expressions
Numeric expressions
Operators and precedence
Primitive types
Text formatting (system words)
Substrings