Strings
Describes strings (string) in
OPL.
Shows how to declare strings in the OPL language.
OPL supports a string data type. The excerpt
{string} Tasks = {"
masonry","carpentry","plumbing","ceiling",
"roofing","painting","windows","facade",
"garden","moving"};
defines and initializes a set of strings. Strings can appear in tuples and index arrays.
Strings are manipulated in the preprocessing phase via ILOG Script. See IBM ILOG Script for OPL for details on the scripting language.
The OPL parser supports the following escape sequences inside literal strings:
| Escape sequence | Meaning |
|---|---|
| \b | backspace |
| \t | tab |
| \n | newline |
| \f | form feed |
| \r | carriage return |
| \" | double quote |
| \\ | backslash |
| \ooo | octal character ooo |
| \xXX | hexadecimal character XX |
To continue a literal string over several lines, you need to escape the new line character:
"first line \
second line"