Naming conventions – overview and description

Overview

- Prefixes for variables

          - Prefixes for types

                    - NC0003: BOOL

                    - NC0004: BIT

                    - NC0005: BYTE

                    - NC0006: WORD

                    - NC0007: DWORD

                    - NC0008: LWORD

                    - NC0013: SINT

                    - NC0014: INT

                    - NC0015: DINT

                    - NC0016: LINT

                    - NC0009: USINT

                    - NC0010: UINT

                    - NC0011: UDINT

                    - NC0012: ULINT

                    - NC0017: REAL

                    - NC0018: LREAL

                    - NC0019: STRING

                    - NC0020: WSTRING

                    - NC0021: TIME

                    - NC0022: LTIME

                    - NC0023: DATE

                    - NC0024: DATE_AND_TIME

                    - NC0025: TIME_OF_DAY

                    - NC0026: POINTER

                    - NC0027: REFERENCE

                    - NC0028: SUBRANGE

                    - NC0030: ARRAY

                    - NC0031: Function block instance

                    - NC0036: Interface

                    - NC0032: Structure

                    - NC0029: ENUM

                    - NC0033: Alias

                    - NC0034: Union

                    - NC0035: __XWORD

                    - NC0037: __UXINT

                    - NC0038: __XINT

          - Prefixes for scopes

                    - NC0051: VAR_GLOBAL

                    - NC0070: VAR_GLOBAL CONSTANT

                    - NC0071: VAR_GLOBAL RETAIN

                    - NC0072: VAR_GLOBAL PERSISTENT

                    - NC0073: VAR_GLOBAL RETAIN PERSISTENT

                    - VAR

                              - NC0053: Program variables

                              - NC0054: Function block variables

                              - NC0055: Function/method variables

                    - NC0056: VAR_INPUT

                    - NC0057: VAR_OUTPUT

                    - NC0058: VAR_IN_OUT

                    - NC0059: VAR_STAT

                    - NC0061: VAR_TEMP

                    - NC0062: VAR CONSTANT

                    - NC0063: VAR PERSISTENT

                    - NC0064: VAR RETAIN

                    - NC0065: I/O variables

- Prefixes for POUs

          - Prefixes for POU type

                    - NC0102: PROGRAM

                    - NC0103: FUNCTIONBLOCK

                    - NC0104: FUNCTION

                    - NC0105: METHOD

                    - NC0106: ACTION

                    - NC0107: PROPERTY

                    - NC0108: INTERFACE

          - Method/property scope

                    - NC0121: PRIVATE

                    - NC0122: PROTECTED

                    - NC0123: INTERNAL

                    - NC0124: PUBLIC

- Prefixes for DUTs

          - NC0151: Structure

          - NC0152: Enumeration

          - NC0153: Union

          - NC0154: Alias

- Prefixes for user-defined types

          - NC0160: User-defined type

 

Detailed description

The following sections contain explanations and examples of which declarations (i.e. at which point in the project) use the individual naming conventions. The declarations samples illustrate cases for which the corresponding prefix would be expected if a prefix was defined with the corresponding naming convention. It should become clear where and how a type or variable can be declared so that the naming convention NC<xxxx> is checked at this point. However, the samples do not show which concrete prefix is defined for the individual naming conventions and would therefore be expected in the sample declarations. There is therefore no OK/NOK comparison.

For concrete examples with a defined prefix, please refer to the page Naming conventions (2).

Basic data types:

NC0003: BOOL

Configuration of a prefix for a variable declaration of type BOOL.

Sample declarations:

For the following variable declarations the prefix configured for NC0003 is used for the formation of the overall prefix, compliance with which is checked during execution of the static analysis.

bStatus         : BOOL;
abVar           : ARRAY[1..2] OF BOOL;
IbInput  AT%I*  : BOOL;

The description of "NC0003: BOOL" is transferrable to the other basic data types:

- NC0004: BIT, NC0005: BYTE

- NC0006: WORD, NC0007: DWORD, NC0008: LWORD

- NC0013: SINT, NC0014: INT, NC0015: DINT, NC0016: LINT, NC0009: USINT, NC0010: UINT, NC0011: UDINT, NC0012: ULINT

- NC0017: REAL, NC0018: LREAL

- NC0019: STRING, NC0020: WSTRING

- NC0021: TIME, NC0022: LTIME, NC0023: DATE, NC0024: DATE_AND_TIME, NC0025: TIME_OF_DAY

- NC0035: __XWORD, NC0037: __UXINT, NC0038: __XINT

 

Nested data types:

NC0026: POINTER

Configuration of a prefix for a variable declaration of type POINTER TO.

Sample declaration:

For the following variable declaration the prefix configured for NC0026 is used for the formation of the overall prefix, compliance with which is checked during execution of the static analysis.

pnID : POINTER TO INT;

NC0027: REFERENCE

Configuration of a prefix for a variable declaration of type REFERENCE TO.

Sample declaration:

For the following variable declaration the prefix configured for NC0027 is used for the formation of the overall prefix, compliance with which is checked during execution of the static analysis.

reffCurrentPosition  : REFERENCE TO REAL;

NC0028: SUBRANGE

Configuration of a prefix for a variable declaration of a subrange type. A subrange type is a data type whose value range only covers a subset of a base type.

Possible basic data types for a subrange type: SINT, USINT, INT, UINT, DINT, UDINT, BYTE, WORD, DWORD, LINT, ULINT, LWORD.

Sample declarations:

For the following variable declaration the prefix configured for NC0028 is used for the formation of the overall prefix, compliance with which is checked during execution of the static analysis.

subiRange   : INT(3..5);
sublwRange : LWORD(100..150);

NC0030: ARRAY

Configuration of a prefix for a variable declaration of type ARRAY[…] OF.

Sample declaration:

For the following variable declaration the prefix configured for NC0030 is used for the formation of the overall prefix, compliance with which is checked during execution of the static analysis.

anTargetPositions  : ARRAY[1..10] OF INT;

 

Instance-based data types:

NC0031: Function block instance

Configuration of a prefix for a variable declaration of a function block type.

Sample declaration:

Declaration of a function block:

FUNCTION_BLOCK FB_Sample

For the following variable declaration the prefix configured for NC0031 is used for the formation of the overall prefix, compliance with which is checked during execution of the static analysis.

fbSample  : FB_Sample;

NC0036: Interface

Configuration of a prefix for a variable declaration of an interface type.

Sample declaration:

Interface declaration:

INTERFACE I_Sample

For the following variable declaration the prefix configured for NC0036 is used for the formation of the overall prefix, compliance with which is checked during execution of the static analysis.

iSample  : I_Sample;

NC0032: Structure

Configuration of a prefix for a variable declaration of a structure type.

Sample declaration:

Declaration of a structure:

TYPE ST_Sample :
STRUCT
    bVar  : BOOL;
    sVar  : STRING;
END_STRUCT
END_TYPE

For the following variable declaration the prefix configured for NC0032 is used for the formation of the overall prefix, compliance with which is checked during execution of the static analysis.

stSample  : ST_Sample;

NC0029: ENUM

Configuration of a prefix for a variable declaration of an enumeration type.

Sample declaration:

Declaration of an enumeration:

TYPE E_Sample :
(
    eMember1 := 1,
    eMember2
);
END_TYPE

For the following variable declaration the prefix configured for NC0029 is used for the formation of the overall prefix, compliance with which is checked during execution of the static analysis.

eSample  : E_Sample;

NC0033: Alias

Configuration of a prefix for a variable declaration of an alias type.

Sample declaration:

Declaration of an alias:

TYPE T_Message : STRING; END_TYPE

For the following variable declaration the prefix configured for NC0033 is used for the formation of the overall prefix, compliance with which is checked during execution of the static analysis.

tMessage  : T_Message;

NC0034: Union

Configuration of a prefix for a variable declaration of a union type.

Sample declaration:

Declaration of a union:

TYPE U_Sample :
UNION
    n1  : WORD;
    n2  : INT;
END_UNION
END_TYPE

For the following variable declaration the prefix configured for NC0034 is used for the formation of the overall prefix, compliance with which is checked during execution of the static analysis.

uSample  : U_Sample;

 

Scopes of variable declarations:

NC0051: VAR_GLOBAL

Configuration of a prefix for a variable declaration between the keywords VAR_GLOBAL and END_VAR.

Sample declaration:

For the following declaration of a global variable, the prefix configured for NC0051 is used for the formation of the overall prefix, compliance with which is checked during execution of the static analysis.

VAR_GLOBAL
    gbErrorAcknowledge : BOOL;
END_VAR

The description of "NC0051: VAR_GLOBAL" is transferrable to other scopes of variable declarations:

- NC0070: VAR_GLOBAL CONSTANT

- NC0071: VAR_GLOBAL RETAIN

- NC0072: VAR_GLOBAL PERSISTENT

- NC0073: VAR_GLOBAL RETAIN PERSISTENT

- NC0053: Program variables (VAR within a program)

- NC0054: Function block variables (VAR within a function block)

- NC0055: Function/method variables (VAR within a function/method)

- NC0056: VAR_INPUT

- NC0057: VAR_OUTPUT

- NC0058: VAR_IN_OUT

- NC0059: VAR_STAT

- NC0061: VAR_TEMP

- NC0062: VAR CONSTANT

- NC0063: VAR PERSISTENT

- NC0064: VAR RETAIN

NC0065: I/O variables

Configuration of a prefix for a variable declaration with AT declaration.

Sample declarations:

For the following variable declarations with AT declaration, the prefix configured for NC0065 is used for the formation of the overall prefix, compliance with which is checked during execution of the static analysis.

ioVar1   AT%I*     : INT;
ioVar2   AT%IX1.0  : BOOL;
ioVar3   AT%Q*     : INT;
ioVar4   AT%QX2.0  : BOOL;

 

POU types:

NC0102: PROGRAM

Configuration of a prefix for the declaration of a program (name of the program in the project tree).

The description of "NC0102: PROGRAM" is transferrable to the other POU types:

- NC0103: FUNCTIONBLOCK

- NC0104: FUNCTION

- NC0105: METHOD

- NC0106: ACTION

- NC0107: PROPERTY

- NC0108: INTERFACE

 

Scopes of methods and properties:

NC0121: PRIVATE

Configuration of a prefix for the declaration of a method or a property (name of the method/property in the project tree), whose access modifier is PRIVATE.

The description of "NC121: PRIVATE" is transferrable to the other scopes of methods and properties:

- NC0122: PROTECTED

- NC0123: INTERNAL

- NC0124: PUBLIC

 

DUTs:

NC0151: Structure

Configuration of a prefix for the declaration of a structure (name of the structure in the project tree).

The description of "NC0151: Structure" is transferrable to the other DUT types:

- NC0152: Enumeration

- NC0153: Union

- NC0154: Alias

 

User-defined types:

NC0160: User defined type

Configuration of a prefix for a user-defined type, e.g. for variables of type PVOID or for instances of the library function block Tc2_System.TON.

For more information on the input options in this area, visit Naming conventions.