Attribute hide

Overview

The pragma {attribute 'hide'} helps you to prevent variables or even whole signatures from being displayed within the functionality of listing components or the input assistant or the declaration part in online mode or the symbol configuration. Only the variable subsequent to the pragma will be hidden.

If you know the instance path to a variable, you can address it in the code even if the {attribute 'hide'} is assigned.

This may be useful for library developers.

Syntax

{attribute 'hide'}

To hide all local variables of a signature, use the attribute hide_all_locals.

Example of a Hidden Variable

The function block myPOU is implemented using the attribute:

FUNCTION_BLOCK myPOU
VAR_INPUT
a:INT;
{attribute 'hide'}
a_invisible: BOOL;
a_visible: BOOL;
END_VAR
VAR_OUTPUT
b:INT;
END_VAR

In the main program 2 instances of function block myPOU are defined:

PROGRAM PLC_PRG
VAR
POU1, POU2: myPOU;
END_VAR

When assigning an input value to POU1, the functionality of listing components that works on typing POU1 in the implementation part of PLC_PRG will display the input variables a and a_visible (and the output variable b). The hidden input variable a_invisible will not be displayed.

Example of a Hidden Library POU

To hide the subordinate POUs (such as methods and properties) in the same way, insert the pragma {attribute 'hide'} also at the beginning of the declarations.

{attribute 'hide'}
FUNCTION_BLOCK FB_A
VAR_INPUT
END_VAR
VAR_OUTPUT
END_VAR
VAR
    iA : INT;
    iCount : INT;
    iInvisible : INT;
END_VAR

{attribute 'hide'}
METHOD METH_Count : INT
VAR_INPUT
END_VAR
iCount := iCount + 1;

{attribute 'hide'}
METHOD METH_Invisible : BOOL
VAR_INPUT
END_VAR
iInvisible := iInvisible + 1;

{attribute 'hide'}
PROPERTY PUBLIC prop_iA : INT

This has the effect that the POUs are not displayed during application development. Nevertheless, they are accessible by entering the instance path.

PROGRAM PLC_PRG
VAR
        fbHidden : FB_A; // Hidden function block from library HiddenFunctionality
        iCounter : INT;
END_VAR
fbHidden.METH_Invisible();
iCounter := fbHidden.iInvisible;

Monitoring is not performed in online mode.