Static Variables - VAR_STATΒΆ

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

You declare static variables locally between the keywords VAR_STAT and END_VAR. CODESYS initializes static variables the first time each block is called.

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.

You can extend static variables with an attribute keyword.

Example

VAR_STAT
        iVarStat1 : INT;
END_VAR

See also