The VAR_INST
instance variables are allowed only in methods. This kind of variable can be accessed
only within the method. You can monitor the variable values of instance variables
in the declaration part of the method.
CODESYS does not save a VAR_INST
method variable in a method stack, but in the stack of the function block instance.
This means that the VAR_INST
variable functions like other Variables of the function block instance, and it is
not reinitialized each time the method is called.
The variable can be extended with an attribute keyword (CONSTANT
, RETAIN
, or PERSISTENT
).
Example
METHOD meth_last : INT VAR_INPUT iVar : INT; END_VAR VAR_INST iLast : INT := 0; END_VAR meth_last := iLast; iLast := iVar;