Attribute 'const_replaced', attribute 'const_non_replaced'

The {attribute 'const_non_replaced'} attribute causes the constant to be replaced in the code, regardless of the setting of the compiler option Replace constants. The attribute has an effect on variables of scalar types, but not on composite types such as arrays and structures.

Insert the pragma {attribute 'const_non_replaced' } to explicitly disable the Replace Constants compiler option. This may be desirable so that a constant is available in the symbol configuration, for example.

Syntax:

{attribute 'const_replaced'}

{attribute 'const_non_replaced'}

Insertion location: Line above the declaration line of the global variable.

Sample:

The constants nTestCon and bTestCon are available in the symbol configuration because the Replace constants option is disabled.

VAR_GLOBAL CONSTANT
    {attribute 'const_non_replaced'}
    nTestCon  :  INT  := 12;    
    {attribute 'const_non_replaced'}
    bTestCon  :  BOOL := TRUE;
    fTestCon  :  REAL := 1.5;
END_VAR

VAR_GLOBAL
    nTestVar  :  INT  := 12;
    bTestVar  :  BOOL := TRUE;
END_VAR

See also: