Constant expressions – Rockwell Automation T6200 Compressor Anti-Surge and Capacity Controller User Manual

Page 141

Advertising
background image

Configuration

8-21

Constant expressions

Constant expressions can be used in all languages for assigning a variable with a value. All
constant expressions have a well defined data type according to their semantics. If you program an
operation between variables and constant expressions having inconsistent data types, it will lead to
syntactic errors when the program is compiled. Below are the syntactic rules for constant
expressions according to possible data types:

BOOL: Boolean

There are only two possible boolean constant expressions. They are reserved keywords TRUE and
FALSE.

DINT: 32 bit (default) integer

32 bit integer constant expressions must be valid numbers between

-2147483648 to

+2147483647. DINT is the default size for integers: such constant expressions do not need any
prefix. You can use "2#", "8#" or "16#" prefixes for specifying a number in respectively binary,
octal or hexadecimal basis.

REAL: Single precision floating point value

Real constant expressions must be valid number, and must include a dot ("."). If you need to enter
a real expression having an integer value, add ".0" at the end of the number. You can use "F" or
"E" separators for specifying the exponent in case of a scientist representation. REAL is the
default precision for floating points: such expressions do not need any prefix.

Examples

Below are some examples of valid constant expressions

TRUE
FALSE
123456
16#abcd
0.0
1.002E3

TRUE boolean expression
FALSE boolean expression
DINT (32 bit) integer
DINT integer in hexadecimal basis
0 expressed as a REAL number
1002 expressed as a REAL number in scientist format

Below are some examples of typical errors in constant expressions

BooVar := 1;
1a2b

0 and 1 cannot be used for booleans
basis prefix ("16#") omitted

Advertising