Naming conventions

In the naming conventions tab you can define naming conventions. Their compliance is accounted for in the static analysis execution. You define mandatory prefixes for the different data types of variables as well as for different scopes, function block types, and data type declarations. The names of all objects for which a convention can be specified are displayed in the project properties as a tree structure. The objects are arranged below organizational nodes.

Naming conventions 1:

Configuration of the naming conventions

Names

Nodes and elements for which a prefix can be defined

The number in brackets after each element, for example "PROGRAM (102)", is the prefix convention number that is output if the naming convention is not followed.

Prefix

You can define the naming conventions by entering the required prefix in this column.

Please note the following notes and options:

  • Several possible prefixes per line
    • Multiple prefixes can be entered separated by commas.
    • Sample: "x, b" as prefixes for variables of data type BOOL. "x" and "b" may be used as prefix for Boolean variables.
  • Regular expressions
    • You can also use regular expressions (RegEx) for the prefix. In this case you have to use @ as additional prefix.
    • Sample: "@b[a-dA-D]" as prefix for variables of data type BOOL. The name of the boolean variable must start with "b", and may be followed by a character in the range "a-dA-D".

Prefixes for variables

Organizational node for all data types and scopes of variables for which a prefix can be defined.

Prefixes for POUs

Organizational node for all POU types and method validity ranges for which a prefix can be defined.

Prefixes for DUTs

Organizational node for all DUT data types for which a prefix can be defined.

 

Naming conventions 2:

Formation of the expected prefix

The prefix expected for the different declarations is formed depending on the configuration of the options found in the Naming conventions (2) dialog.

On the Naming conventions (2) page you will also find explanations on how the expected prefix is formed, as well as some samples.

Naming conventions 3:

Placeholder {datatype} with alias variables and properties

Please also note the possibilities of the placeholder {datatype}, which you can use for the prefix definition of alias variables and properties.

Naming conventions 4:

Local prefix definition for structured types

For variables of structured types, you can specify a prefix locally in the data type declaration using the 'nameprefix' attribute.

Syntax of convention violations in the message window

Each naming convention has a unique number (shown in parentheses after the convention in the naming convention configuration view). If a violation of a convention or a preset is detected during the static analysis, the number is output in the error list together with an error description based on the following syntax. The abbreviation "NC" stands for "Naming Convention".

Syntax: "NC<prefix convention number>: <convention description>"

Sample for convention number 151 (DUTs of type Structure): "NC0151: Invalid type name 'STR_Sample'. Expected prefix 'ST_'"

Temporary deactivation of naming conventions

Individual conventions can be disabled temporarily, i.e. for particular code lines. To this end you can add a pragma or an attribute in the declaration or implementation part of the code. For variables of structured types you may specify a prefix locally via an attribute in the data type declaration. For further information please refer to Pragmas and attributes.

 

Overview of naming conventions

An overview of naming conventions can be found under Naming conventions – overview and description.