Placeholder {datatype}
For variables of type Alias and for properties, the placeholder "{datatype}" can be defined as a prefix in the "Naming Conventions" tab. The placeholder {datatype} is thereby replaced by the prefix that is defined for the data type of the alias or for the data type of the property. The static analysis thus reports errors for all alias variables that do not possess the prefix for the data type of the alias or for all properties that do not possess the prefix for the data type of the property.
The placeholder "{datatype}" can also be combined with further prefixes in the prefix definition, e.g. to "P_{datatype}_".
Example 1 for an alias variable:
- In the project there is an alias "TYPE MyMessageType : STRING; END_TYPE" as well as a variable of this type (var : MyMessageType;).
- Prefix definitions
- Prefix for the variable data type alias (33) = "{datatype}"
- Prefix for the variable data type STRING (19) = "s"
- In the prefix definitions mentioned the data type prefix "s" is expected for a variable of the alias type "MyMessageType" (e.g. for the variable "var").
Example 2 for an alias variable:
- Same situation as in example 1 for an alias variable, the only difference being:
- Prefix for the variable data type alias (33) = "al_{datatype}"
- In this case the data type prefix "al_s" is expected for a variable of the alias type "MyMessageType".
Example of a property:
- Prefix definitions
- Prefix for the method/property scope PRIVATE (121) = "priv_"
- Prefix for the POU type PROPERTY (107) = "P_{datatype}"
- Prefix for the variable data type LREAL (18) = "f"
- Note: For POUs with an access modifier (methods or properties), the combination of the prefix for the scope (NC0121-NC0124: PRIVATE/PROTECTED/INTERNAL/PUBLIC) and the prefix for the POU type (NC0105 for method, NC0107 for property) is expected as the overall prefix.
- With the prefix definitions mentioned the overall prefix "priv_P_f" is thus expected for a property with the access modifier PRIVATE and the data type LREAL.