beautypg.com

Variables initialization, L-force | plc designer – Lenze PLC Designer PLC Designer (R3-1) User Manual

Page 968

background image

L-force | PLC Designer

Programming Reference

966

DMS 4.1 EN 03/2011 TD29

(6) POUs in »PLC Designer« V3.x Libraries
POU names in »PLC Designer« V3.x libraries do not get a library prefix, because using
the namespace takes the function of a prefix. For creating method names the same
rules apply as for actions. Possible inputs of a method should get english comments.
Also a short description of a method should be added in its declaration. Interface
names should start with letter "I", for example: ICANDevice

(7) Visualization names

Note: Currently just avoid to name a visualization like another object in the project,
because this would cause problems in case of visualization changes.

16.1.3

Variables Initialization
The default-initialization value is 0 for all declarations, but user defined initialization
values can be added in the declaration of each variable and data type.
The user defined initialization is brought about by the assignment operator ":=" and
can be any valid ST expression. Thus constant values as well as other variables or
functions can be used to define the init value. The programmer just has to make sure
that a variable used for the initialization of another variable is already initialized itself.

Examples for valid variable initializations:
VAR

var1:INT := 12;

(* Integer variable with initial value of 12*)

x : INT := 13 + 8;

(* init value defined by an expression with constants *)

y : INT := x + fun(4);

(* init value defined by an expression containing a function call;
be aware of the order in this case! *)

z : POINTER TO INT := ADR(y);

(* not described by the IEC61131-3: init value defined by a
address function; Be careful in this case: the pointer will not be
initialized during online change! *)

END_VAR
see also: Arbitrary expressions for variable initialization

Note: As from compiler version 3.3.2.0 variables of global variables lists are always
initialized before local variables of a POU.