Attribute initialize_on_call, Attribute init_namespace, L-force | plc designer – Lenze PLC Designer PLC Designer (R3-1) User Manual

Page 999

Advertising
background image

L-force | PLC Designer

Programming Reference

DMS 4.1 EN 03/2011 TD29

997

Attribute Initialize_on_call
The pragma {attribute 'initialize_on_call'} may be added to input variables. An input of
a function block with this attribute will be initialized at any call of the function block. If
an input expects a pointer and if this pointer has been removed due to an online
change, then the input will be set to NULL.
Syntax:
{attribute 'initialize_on_call’}

Attribute Init_Namespace
A variable of type STRING or WSTRING, which is provided with the pragma {attribute
'init_namespace'}
, will be initialized with the current namespace, this is the path of
the instance of the function block this variable is contained. Applying this pragma
presumes the use of the additional attribute 'noinit' for the string variable and the
attribute 'reflection' for the corresponding function block.
Syntax:
{attribute 'init_namespace’}

Example:
The function block POU is provided with all necessary attributes:

{attribute 'reflection'}
FUNCTION_BLOCK POU
VAR_OUTPUT
{attribute 'no_init'}
{attribute 'instance-path'}
myStr: STRING;
END_VAR

Within the main program PLC_PRG an instance "fb" of the function block POU is
defined:

PROGRAM PLC_PRG
VAR
fb:POU;
newString: STRING;
END_VAR
newString:=fb.myStr;

The variable myStr will be initialized with the current namespace, e.g.
"PLCWinNT.Application.PLC_PRG.fb". This value will be assigned to newString within
the main program.

Advertising