Attribute 'init_namespace'

The pragma causes a variable of type STRING or WSTRING, which is declared in a library function block with this pragma, to be initialized with the current namespace of the library when it is used in the project.

Syntax: {attribute 'init_namespace'}

Insertion location: Line above the declaration line of the variable in a library function block

Example:

The function block FB_Sample has the required attributes:

FUNCTION_BLOCK FB_Sample 
VAR_OUTPUT
    {attribute 'init_namespace'} 
    sNamespace : STRING; 
END_VAR 

An instance fbSample of the function block FB_Sample is defined within the main program MAIN

PROGRAM MAIN
VAR
    fbSample : FB_Sample;
    sMyNamespace : STRING;
END_VAR
sMyNamespace := fbSample.sNamespace;

The variable sNamespace is initialized with the current namespace, for example Tc3_TestLib. This value is assigned to sMyNamespace in the main program.

See also: