User-defined attributes

User-defined attributes are any application-defined or user-defined attributes that you can apply to POUs, actions, data type definitions and variables. You can query a user-defined attribute with the help of conditional pragmas before the compilation of the application.

Note

You can query user-defined attributes with conditional pragmas with the operator hasattribute.

More detailed information and examples can be found in the chapter ‘Conditional pragmas’.

Syntax:

{attribute 'attribute'}

Example for POUs and actions

Attribute 'vision' for function fun1

{attribute 'vision'}
FUNCTION fun1 : INT
VAR_INPUT
 i : INT;
END_VAR

Example for variables

Attribute 'DoCount' for variable ivar :

PROGRAM PLC_PRG
VAR
 {attribute 'DoCount'};
 ivar:INT;
 bvar:BOOL;
END_VAR

Example for data types

Attribute 'aType' for data type DUT_1:

{attribute 'aType'}
TYPE DUT_1 :
STRUCT
 a:INT;
 b:BOOL;
END_STRUCT
END_TYPE

See also