Variable: VAR_STAT Permalink

This functionality is an extension of the IEC 61131-3 standard.

You declare static variables locally between the keywords ‎VAR_STAT‎ and ‎END_VAR‎. Static variables are initialized on download.

You can access static variables only from within the namespace where the variables are declared (like static variables in C). But static variables retain their values when the application leaves the block. For example, you can use static variables as counters for function calls.

The variable can be extended with an attribute keyword (‎CONSTANT‎, ‎RETAIN‎, or ‎PERSISTENT‎).

Example

VAR_STAT
        iVarStat1 : INT;
END_VAR