L-force | plc designer – Lenze PLC Designer PLC Designer (R3-1) User Manual
Page 1084

L-force | PLC Designer
Programming Reference
1082
DMS 4.1 EN 03/2011 TD29
Syntax:
__NEW (
The operator will create a new object of the specified type
pointer to that
returned the operation is failed.
If
operator creates an array of scalar types with the size length.
Example:
pScalarType := __New(ScalarType, length);
Note: A copy code in online change of dynamically created objects is not possible!
Therefore only function blocks out of libraries (because they can't change) and
function blocks with attribute 'enable_dynamic_creation' are allowed for the __New-
Operator.
If a function block change with this flag so that copy code would be necessary, an error
message is produced.
Note: The code for memory allocation needs to be non-reentrant.
A semaphor (SysSemEnter) is used to avoid two tasks try to allocate memory at the
same time. Thus, extensive usage of __New may produce higher jitter.
Example with a scalar type:
TYPE DUT :
STRUCT
a,b,c,d,e,f : INT;
END_STRUCT
END_TYPE
PROGRAM PLC_PRG
VAR
pDut : POINTER TO DUT;
bInit: BOOL := TRUE;
bDelete: BOOL;
END_VAR