String literals in OpenCReports can be either single or double quoted. Some examples:
"apple" ’apple’ "I’ve eaten an apple" ’This an "apple".’
The values of these strings are:
apple apple I’ve eaten an apple This an "apple".
We can see how the other quoting character can be used as part of the string value.
String literals can also use BASIC language style double quoting to embed a single quoting character used for quoting the string itself:
’apple’’’ ’apple’’pear’ ’apple’’’’pear’ "apple""" "apple""pear" "apple""""pear"
The values of these strings are:
apple’ apple’pear apple’’pear apple" apple"pear apple""pear
String literals can also use C language string continuation if there's at least one whitespace character (space, TAB or new line) between doubled quoting characters. String continuation can also switch quoting characters without whitespace between quoting.
"apple" "pear" "apple" ’pear’ "apple"’pear’
The value of all these strings is:
applepear
Numeric constants can be integer or fractional numbers with or without the so called e-notation or scientific notation. Some examples:
1 1.234 1e4 1e-4 1.234e-5
E-notation means that that number preceding the letter "e" or "E" is multiplied by ten to the power of the number after the letter "e" or "E", the latter being an integer value. The values of the above examples are:
1 1.234 10000 0.0001 0.00001234
Numbers greater than 0 and less than 1 can be written with or without the leading zero.
0.123 .123
Technically, there are no negative numeric constants. Instead, the number and the unary minus operator (see Unary operators) are initially handled separately. Then the expression optimizer merges them, creating the negative numeric constant.
Boolean constants evalutate to numeric constans
1
and 0
.
The boolean constants are:
yes no true false
There are no datetime constants per se, although expressions
like stodt('1980-06-30 16:00:00')
or
interval('2 months')
(i.e. function calls
with constant arguments that result in a
datetime
value) are implicitly turned into
constants by the expression optimizer.
Constant expressions are ones that only contain constant values (of any type) and operators or functions.