Temporary variables - var_temp, Static variables - var_stat, External variables - var_external – Lenze PLC Designer PLC Designer (R3-1) User Manual

Page 978: Attribute keywords for variable types, L-force | plc designer

Advertising
background image

L-force | PLC Designer

Programming Reference

976

DMS 4.1 EN 03/2011 TD29

16.1.15

Temporary Variables - VAR_TEMP
This feature is an extension to the IEC 61131-3 standard.
VAR_TEMP declarations are only possible within programs and function blocks. Those
variables are also only accessible within the body of the program or function block.
VAR_TEMP declared variables are (re)initialized every time the POU is called.
The variables have to be declared locally between the keywords VAR_TEMP and
END_VAR.

16.1.16

Static Variables - VAR_STAT
This feature is an extension to the IEC 61131-3 standard.
Static variables can be used in function blocks, methods and functions. They have to be
declared locally between the keywords VAR_STAT and END_VAR and will be initialized
at the first call of the respective POU.
Static variables are only accessible within the scope in which they are declared (like a
static variable in C), but like a global variable do not loose its value after the POU is left.
For example in a function they might be used as a counter for the number of function
calls.
Regard the possibility of adding an attribute to "VAR_STAT".

16.1.17

External variables - VAR_EXTERNAL
These are global variables which are "imported" into the POU.
They have to be declared locally between the keywords VAR_EXTERNAL and END_VAR
and in the global variable list. The declaration must exactly match the global
declaration. If the global variable does not exist, an error message will appear.

Note: In CoDeSys it is not necessary to define variables as external. These keyword is
provided in order to maintain compatibility to IEC 61131-3.

Example:

VAR_EXTERNAL
iVarExt1:INT; (* 1st external variable *)
END_VAR

16.1.18

Attribute Keywords for Variable Types
The following attribute keywords can be added to the declaration of the variables
"type" in order to specify the scope:
RETAIN: See remanent variables of type RETAIN
PERSISTENT: See remanent variables of type PERSISTENT
CONSTANT: See constants

Advertising