Constants
String
All string literals must be contained within single quotation marks
( ' ' ). All ECL code is UTF-8 encoded, which means that all strings are
also UTF-8 encoded, whether Unicode or non-Unicode strings. Therefore, you
must use a UTF-8
UTF-8
editor (such as the ECL IDE
ECL IDE
program).
To include the single quote character (apostrophe) in a constant
string, prepend a backslash (\). To include the backslash character (\) in
a constant string, use two backslashes (\\) together.
STRING20 MyString2 := 'Fred\'s Place';
//evaluated as: "Fred's Place"
STRING20 MyString3 := 'Fred\\Ginger\'s Place';
//evaluated as: "Fred\Ginger's Place"
Other available escape characters are:
\t
tab
\n
new line
\r
carriage return
\nnn
3 octal digits (for any other character)
\uhhhh
lowercase "u" followed by 4 hexadecimal digits (for any
other UNICODE-only character)
MyString1 := 'abcd';
MyString2 := U'abcd\353'; // becomes 'abcdë'
Hexadecimal
Hexadecimal
string constants
string constants
must begin with a leading “x” character. Only
valid hexadecimal values (0-9, A-F) may be in the character string and
there must be an even number of characters.
DATA2 MyHexString := x'0D0A'; // a 2-byte hexadecimal string
Data string
Data string
constants
constants
must begin with a leading “D” character. This is
directly equivalent to casting the string constant to DATA.
MyDataString := D'abcd'; // same as: (DATA)'abcd'
Unicode string
Unicode string
constants must begin with a leading “U”
character. Characters between the quotes are utf8-encoded and the type of
the constant is UNICODE.
MyUnicodeString1 := U'abcd'; // same as: (UNICODE)'abcd'
MyUnicodeString2 := U'abcd\353'; // becomes 'abcdë'
MyUnicodeString3 := U'abcd\u00EB'; // becomes 'abcdë'
VARSTRING string constants
VARSTRING string constants
must begin with a leading “V” character. The
terminating null byte is implied and type of the constant is
VARSTRING.
MyVarString := V'abcd'; // same as: (VARSTRING)'abcd'
QSTRING string constants
QSTRING string constants
must begin with a leading “Q” character. The
terminating null byte is implied and type of the constant is
VARSTRING.
MyQString := Q'ABCD'; // same as: (QSTRING)'ABCD'
Numeric
Numeric constants containing a decimal portion are treated as REAL
values (scientific notation is allowed) and those without are treated as
INTEGER
INTEGER
(see Value Types). Integer
constants may be decimal, hexadecimal, or binary values.
Hexadecimal
Hexadecimal
values are specified with either a leading “0x” or a
trailing “x” character. Binary values
Binary values
are specified with either a leading “0b” or a trailing “b”
character.
MyInt1 := 10; // value of MyInt1 is the INTEGER value 10
MyInt2 := 0x0A; // value of MyInt2 is the INTEGER value 10
MyInt3 := 0Ax; // value of MyInt3 is the INTEGER value 10
MyInt4 := 0b1010; // value of MyInt4 is the INTEGER value 10
MyInt5 := 1010b; // value of MyInt5 is the INTEGER value 10
MyReal1 := 10.0; // value of MyReal1 is the REAL value 10.0
MyReal2 := 1.0e1; // value of MyReal2 is the REAL value 10.0