For variables
Whenever possible, you should name variables in Hungarian notation in applications and libraries. Find a meaningful, short, English name for each variable as a base name, which can consist of several words. Write the first letter of each word in uppercase, the remaining letters in lowercase. In front of the base name, append a prefix in lowercase to indicate the data type of the variable.
Example: iFileSize : INT;
Identifier designation recommendation for Data Type | Prefix | Description |
---|---|---|
|
| We expressly recommend |
| Reserved | |
|
| Bit string; not for arithmetic operations |
|
| Bit string; not for arithmetic operations |
|
| Bit string; not for arithmetic operations |
|
| Bit string; not for arithmetic operations |
|
| Arithmetic integer data type, 8-bit |
|
| Arithmetic integer data type, 8-bit |
|
| Arithmetic integer data type, 16-bit |
|
| Arithmetic integer data type, 16-bit |
|
| Arithmetic integer data type, 32-bit |
|
| Arithmetic integer data type, 32-bit |
|
| Arithmetic integer data type, 64-bit |
|
| Arithmetic integer data type, 64-bit |
|
| Arithmetic floating-point data type, 32-bit |
|
| Arithmetic floating-point data type, 64-bit |
|
| Single-byte string of variable length (default setting: 80 characters) |
|
| Double-byte string of variable length (default setting: 80 characters) |
|
| Time duration, 32-bit |
|
| Time duration, 64-bit |
|
| Time of day, 32-bit |
|
| Time of day, 64-bit |
|
| Date and time |
|
| |
|
| Calender date |
|
| Calender date |
|
| |
|
| |
Enumeration |
|
VAR bySubIndix: BYTE; xFlag: BOOL; udiCounter: UDINT; END_VAR
Identifier designation recommendation for | Description | Example |
---|---|---|
Nested declaration | Prefixes are attached successively in the order of declaration. |
|
Function block instance Variable of user-defined data type | Prefix: Abbreviation for the name of the function block or data type | cansdoReceivedTelegram: CAN_SDOTelegram; TYPE CAN_SDOTelegram : (* prefix: sdo *) STRUCT wIndex: WORD; bySubIndex:BYTE; byLen:BYTE; aby: ARRAY [0..3] OF BYTE; END_STRUCT END_TYPE |
Local constant Local constant variable | Prefix: | VAR CONSTANT c_uiSyncID: UINT := 16#80; END_VAR |
Global variable | An additional prefix is appended to the library prefix.
| VAR_GLOBAL CAN_g_iText: INT; END_VAR |
Global constants Global constant variable | An additional prefix is appended to the library prefix.
| VAR_GLOBAL CONSTANT CAN_gc_dwExample: DWORD; END_VAR |