Constants
2, 2.1828, 3.5cm, "string", T(two, two, deux)
Stack | Position | Description |
---|---|---|
Stack(In) | Top | - |
Stack(Out) | Top | Value of the constant |
InstantView® knows the following constants:
Type | Example | Value on the stack |
---|---|---|
Integer | 3 | integer |
Numeric | 3.14 | transient object CX_NUMERIC |
Value | 3.14m | transient object CX_VALUE |
String | "abc\ndef" | the character string |
multiple string | T("three", three, trois) | multilingual character string (Note: The quote characters (") can be omitted if the partial text syntactically corresponds to an identifier) |
Flag | NF_SET_PRECISION | Flag |
INVALID | INVALID | Result when reading a slot that does not exist; All variables stop before the first value assignment INVALID |
ACCESS_DENIED | ACCESS_DENIED | the result when reading access to data for which no Access rights exist |
Negative numerical constants - Integer, Numeric, Value - must be enclosed in round brackets (to clearly distinguish the minus sign from the operator - ). The minus sign can be placed before or after the number. For some integer constants there are predefined identifiers.
A dimensioned constant (an object of the class CX_VALUE) is created when a whole or real number is followed by the name of a unit of measurement (in English). If the name of the unit of measurement (e.g. m for metre) was also used as a variable name or name of a statement, this has priority ( see example).
Special characters within a string are expressed in the same way as in C/C++:
hexadecimal | Meaning | |
---|---|---|
\n | 0x0d | CR |
\r | 0x0a | LF |
\f | 0x0c | FF |
\t | 0x09 | Tab |
\b | 0x08 | BS |
\\ | 0x5c | the sign \ |
\" | 0x22 | the sign " |
\NN | Code of a byte as an octal number |
\xNN | Code of a byte as hexadecimal number | Ex: "\x41" -> "A" |
\U+NNNNNN | Unicode code of a letter as hexadecimal number | Ex: "\U+20AC" -> "€" |
When specifying characters via octal or hexadecimal values, a maximum of as many characters are interpreted as a number as N occurs in the above table. You can specify fewer characters if they are not followed by a character that could also be interpreted as part of this number. In this case, the number must be filled with leading zeros.
Ex: "\U+20ACB" is interpreted as 1 Unicode character, but "\U+0020ACB" as "€B".
If strings of the form "class access::expression" are required as parameters (see instruction SetFormat), the string constant can also be written in the form Path(class::access-expression), whereby here - in contrast to the string notation "class::access-expression" - only syntactically correct constructions are possible. This notation is necessary if strings occur as function parameters in the access expression which themselves contain substrings in \"....\" (see example).
Note: The number of digits after the decimal point determines the precision of the CX_NUMERIC object
further examples ...