Introduction

Provides an overview of the use of strings in IBM ILOG Script.

A string literal is zero or more characters enclosed in double (“) or single (’) quotes.

Note:

For C/C++ programmers: Except for the use of single quotes, string literals have the same syntax as in C and C++.

Here are examples of string literals:


"My name is Hal"  
’My name is Hal’  
’"Hi there", he said’  
"3.14"  
"Hello, world\n"  

In these examples, the first and second strings are identical.

The backslash character \ can be used to introduce an escape sequence, which stands for a character which cannot be directly expressed in a string literal.

Table 1. Escape sequences in strings
Escape sequence Stands for
\n Newline
\t Tab
\\ Backslash character (\)
\” Double quote (")
\’ Single quote (’)
\b Backspace
\f Form feed
\r Carriage return
\xhh The character whose ASCII code is hh, where hh is a sequence of two hexadecimal digits.
\ooo The character whose ASCII code is ooo, where ooo is a sequence of one, two, or three octal digits.

Here are examples of string literals using escape sequences:

Table 2. Examples of string literals using escape sequences
String literal Stands for
"Read 'The Black Bean'" Read ‘The Black Bean’
’"Hello", he said’ “Hello”, he said
"c:\\temp" c:\temp
"First line\nSecond line\nThird line"

First line

Second line

Third line

"\xA9 1995-1997" © 1995-1997

When a string is converted to a number, an attempt is made to parse it as a number literal. If the string does not represent a valid number literal, the conversion yields NaN.