Skip to main content

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

BOOL

x

We expressly recommend x as the prefix for Boolean variables in order to distinguish them from identifiers of the data type BYTE. The prefix indicates the view of an IEC programmer.

b

Reserved

BYTE

by

Bit string; not for arithmetic operations

WORD

w

Bit string; not for arithmetic operations

DWORD

dw

Bit string; not for arithmetic operations

LWORD

lw

Bit string; not for arithmetic operations

SINT

si

Arithmetic integer data type, 8-bit

USINT

usi

Arithmetic integer data type, 8-bit

INT

i

Arithmetic integer data type, 16-bit

UINT

ui

Arithmetic integer data type, 16-bit

DINT

di

Arithmetic integer data type, 32-bit

UDINT

udi

Arithmetic integer data type, 32-bit

LINT

li

Arithmetic integer data type, 64-bit

ULINT

uli

Arithmetic integer data type, 64-bit

REAL

r

Arithmetic floating-point data type, 32-bit

LREAL

lr

Arithmetic floating-point data type, 64-bit

STRING

s

Single-byte string of variable length (default setting: 80 characters)

WSTRING

ws

Double-byte string of variable length (default setting: 80 characters)

TIME

tim

Time duration, 32-bit

LTIME

ltim

Time duration, 64-bit

  • TIME_OF_DAY

  • TOD

tod

Time of day, 32-bit

  • LTIME_OF_DAY

  • LTOD

ltod

Time of day, 64-bit

  • DATE_AND_TIME

  • DT

dt

Date and time

  • LDATE_AND_TIME

  • LDT

ldt

DATE

  • dat

  • d

Calender date

LDATE

  • ldat

  • ld

Calender date

POINTER

p

ARRAY

a

Enumeration

e

Example 305. Example
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.

pabyTelegramData: POINTER TO ARRAY [0..7] OF BYTE;

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: c_, followed by the type prefix and the variable name

VAR CONSTANT
    c_uiSyncID: UINT := 16#80;
END_VAR

Global variable

An additional prefix is appended to the library prefix.

g_

VAR_GLOBAL
    CAN_g_iText: INT;
END_VAR

Global constants

Global constant variable

An additional prefix is appended to the library prefix.

gc_

VAR_GLOBAL CONSTANT
    CAN_gc_dwExample: DWORD;
END_VAR