Attribute: init_namespace
The effect of this pragma is that a variable of the type STRING
or WSTRING
, which is declared in a library function block with this pragma, is initialized when used in the project with the current namespace of the library.
Syntax
{attribute 'init_namespace'}
Insert location: The line above the line with the declaration of the variables in a library function block.
Example 272.
The function block POU is provided with the necessary attributes:
FUNCTION_BLOCK POU VAR_OUTPUT {attribute 'init_namespace'} myStr: STRING; END_VAR
An instance fb
of the function block POU is defined within the main program PLC_PRG:
PROGRAM PLC_PRG VAR fb:POU; newString: STRING; END_VAR newString := fb.myStr;
The myStr
variable is initialized with the current namespace (example: MyLib
). This value is assigned to newString
in the main program.