Instance Variables - VAR_INSTΒΆ

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.

VAR_INST variables are permitted in methods only and you can access these variables only within the method. The variable values of instance variables are monitored in the declaration section of the method.

You can extend instance variable with an attribute keyword.

Example

METHOD meth_last : INT
VAR_INPUT
  iVar : INT;
END_VAR
VAR_INST
  iLast : INT := 0;
END_VAR
meth_last := iLast;
iLast := iVar;

See also