Variable: CONSTANT
Constant variables are declared in global variable lists or in the declaration part of programming objects. In implementations, constant variables can be accessed as read-only via the instance path.
Syntax
<scope> CONSTANT
<identifier> : <data type> := <initial value> ;
END_VAR
<scope> : VAR | VAR_INPUT | VAR_STAT | VAR_GLOBAL
<data type>: <elementary data type> | <user defined data type> | <function block>
<initial value> : <literal value> | <identifier> | <expression>Always assign an initialization value when declaring a constant variable. Then the constant cannot be written any more.
Example 92. Example
Declaration
VAR CONSTANT
c_rTAXFACTOR : REAL := 1.19;
END_VARCall
rPrice := rValue * c_rTAXFACTOR;
You have read-only access to constant variables in an implementation. Constant variables are located to the right of the assignment operator.
For more information, see: Operands