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:
- A variable that contains a series of characters.
- A string literal, which is a series of characters delimited by
double quote marks. The literal is of type STRING.
- A substring of a literal or variable 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";
For an example that shows the effect of parentheses on the
use of a plus (+) sign, see Expressions.
- Any other function invocation that returns a series of characters.
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, field, 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.