Attribut 'const_replaced', Attribut 'const_non_replaced'

Das Attribut {attribute 'const_non_replaced'} bewirkt, dass die Konstante im Code ersetzt wird, unabhängig von der Einstellung der Compileroption Konstanten ersetzen. Das Attribut hat eine Auswirkung auf Variablen von skalaren Typen, aber nicht auf zusammengesetzte Typen wie Arrays und Strukturen.

Das Pragma {attribute 'const_non_replaced'} fügen Sie entsprechend ein, um die Compileroption Konstanten ersetzen explizit zu deaktivieren. Dies kann beispielsweise erwünscht sein, damit eine Konstante in der Symbolkonfiguration verfügbar ist.

Syntax:

{attribute 'const_replaced'}

{attribute 'const_non_replaced'}

Einfügeort: Zeile oberhalb der Deklarationszeile der globalen Variablen.

Beispiel:

Die Konstanten nTestCon und bTestCon sind in der Symbolkonfiguration verfügbar, weil die Option Konstanten ersetzen deaktiviert ist.

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

Siehe auch: