User-defined attributes
Custom attributes are any project or user-defined attributes that you can apply to POUs, actions, data type definitions and variables. You can query a custom attribute before compiling the PLC project using conditional pragmas.
You can query custom attributes with conditional pragmas using the hasattribute operator. |
Syntax: {attribute 'attribute'}
Examples of POUs and actions:
Attribute 'vision' for function F_Sample:
{attribute 'vision'}
FUNCTION F_Sample : INT
VAR_INPUT
nSample : INT;
END_VAR
Examples for variables:
Attribute 'DoCount' for variable nVar:
PROGRAM MAIN
VAR
{attribute 'DoCount'};
nVar : INT;
bVar : BOOL;
END_VAR
Example for data types:
Attribute 'aType' for data type ST_MyType:
{attribute 'aType'}
TYPE ST_MyType :
STRUCT
nTest : INT;
bTest : BOOL;
END_STRUCT
END_TYPE
See also: