A variable of type STRING or WSTRING, which is declared with the pragma {attribute init_namespace} in a library, will be initialized with the current namespace of that library. For further information, refer to the description of the library management.
{attribute 'init_namespace'}
The function block POU is provided with all necessary attributes:
FUNCTION_BLOCK POU
VAR_OUTPUT
{attribute 'init_namespace'}
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, for example MyLib.XY. This value will be assigned to newString within the main program.