Input and output variables - var_in_out, Global variables - var_global, L-force | plc designer – Lenze PLC Designer PLC Designer (R3-1) User Manual

Page 977

Advertising
background image

L-force | PLC Designer

Programming Reference

DMS 4.1 EN 03/2011 TD29

975

Output variables in functions and methods:
According to IEC 61131-3 draft 2, functions (and methods) can have additional
outputs. Those must be assigned in the call of the function like this:

fun(iIn1 := 1, iIn2 := 2, iOut1 => iLoc1, iOut2 => iLoc2);

The return value of the function fun will be written to the e.g. locally declared variables
loc1
and loc2.

16.1.13

Input and Output Variables - VAR_IN_OUT
Between the key words VAR_IN_OUT and END_VAR all variables are declared that
serve as input and output variables for a POU.

Note: With variables of this type the value of the transferred variable is changed
("transferred as a pointer", Call-by-Reference). That means that the input value for
such variables cannot be a constant. For this reason, even the VAR_IN_OUT variables
of a function block can not be read or written directly from outside via
<functionblockinstance><in/outputvariable>.

Example:

VAR_IN_OUT
iInOut1:INT; (* 1. Inputoutputvariable *)
END_VAR

16.1.14

Global Variables - VAR_GLOBAL
„Normal" variables, constants, external or remanent variables that are known
throughout the project can be declared as global variables.

Note: A variable defined locally in a POU with the same name as a global variable
will have priority within the POU.
Note: As from compiler version 3.2.0.0 global variables always will be initialized
before local variables of POUs.

The variables have to be declared locally between the keywords VAR_GLOBAL and
END_VAR. Regard the possibility of adding an attribute to "VAR_GLOBAL".
A variable is recognized as a global variable by a preceding dot: for example
".iGlobVar1".
For detailed information on multiple use of variable names, the global scope operator
"." and name spaces see: Global Scope Operator.
Use Global Variables lists (GVLs) to structure and handle global variables within a
project. A "GVL" can be added via the Add Object command.

Advertising