Attribute init_on_onlchange, Attribute instance-path, L-force | plc designer – Lenze PLC Designer PLC Designer (R3-1) User Manual

Page 1000

Advertising
background image

L-force | PLC Designer

Programming Reference

998

DMS 4.1 EN 03/2011 TD29

Attribute Init_On_Onlchange
The pragma {attribute 'init_on_onlchange'} attached to a variable will cause this
variable to get initialized with each online change.
Syntax:
{attribute 'init_on_onlchange’ }

Attribute Instance-path
The pragma {attribute 'instance-path'} may be added to a local string variable that, in
consequence, will be initialized with the device tree path of the POU this string
variable belongs to. This may be a useful feature for error messages. Applying this
pragma presumes the use of the attribute 'reflection' for the corresponding POU and
the additional attribute 'noinit' for the string variable.
Syntax:
{attribute 'instance-path’}

Example:
Assume the following function block being equipped with the attribute 'reflection':

{attribute 'reflection'}
FUNCTION_BLOCK POU
VAR
{attribute 'instance-path'}
{attribute 'noinit'}
str: STRING;
END_VAR

An instance of the function block is called in the program PLC_PRG:

PROGRAM PLC_PRG
VAR
myPOU:POU;
myString: STRING;
END_VAR
myPOU();
myString:=myPOU.str;

The instance myPOU having been initialized the string variable "str" will be assigned
the path of the instance myPOU of POU, e.g. "PLCWinNT.Application.PLC_PRG.myPOU".
This path will be assigned to variable "myString" within the main program.

Advertising