Variables

All variables used in programs must be first declared in the variable editor. Each variable belongs to a group and is must be identified by a unique name within its group.

Groups

A group is a set of variables. A group either refers to a physical class of variables, or identifies the variables local to a program or user defined function block. Below are the possible groups:

GLOBAL Internal variables known by all programs
RETAIN Non volatile internal variables known by all programs
%I... Channels of an input board - variables with same data type linked to a physical input device
%Q... Channels of an output board - variables with same data type linked to a physical output device
PROGRAMxxx All internal variables local to a program
(the name of the group is the name of the program)
UDFBxxx All internal variables local to a User Defined Function Block plus its IN and OUT parameters
(the name of the group is the name of the program)

Data type and dimension

Each variable must have a valid data type. It can be either a basic data type or a function block. In that case the variable is an instance of the function block. Physical I/Os must have a basic data type. Instances of function blocks can refer either to a standard or "C" embedded block, or to a User Defined Function Block.

If the selected data type is STRING, you must specify a maximum length, that cannot exceed 255 characters.

Refer to the list of available data types for more information. Refer to the section describing function blocks for further information about how to use a function instance.

Additionally, you can specify dimension(s) for an internal variable, in order to declare an array. Arrays have at most 3 dimensions. All indexes are 0 based. For instance, in case of single dimension array, the first element is always identified by ArrayName[0]. The total number of items in an array (merging all dimensions) cannot exceed 65535.

Naming a variable

A variable must be identified by a unique name within its parent group. The variable name cannot be a reserved keyword of the programming languages and cannot have the same name as a standard or "C" function or function block. A variable should not have the same name as a program or a user defined function block.

The name of a variable should begin by a letter or an underscore ("_") mark, followed by letters, digits or underscore marks. It is not allowed to put two consecutive underscores within a variable name. Naming is case insensitive. Two names with different cases are considered as the same.

Naming Physical I/Os

Each I/O channel as a predefined symbol that reflects its physical location. This symbol begins with "%I" for an input and "%Q" for an output, followed by a letter identifying the physical size of the data. Then comes the location of the board, expressed on 1 or two numbers, and finally the 0 based index of the channel within the board. All numbers are separated by dots. Below are the possible prefixes for IO symbols:

%IX 1 byte input - BOOL or SINT
%QX 1 byte output - BOOL or SINT
%IW 2 bytes input - INT
%QW 2 bytes output - INT
%ID 4 bytes input - DINT or REAL
%QD 4 bytes input - DINT or REAL
%IL 8 bytes input - LINT or LEAL
%QL 8 bytes output - LINT or LEAL
%IS STRING input
%QS STRING output

Additionally, you can give an alias (a readable name) to each I/O channel. In that case, either the "%" name or the alias can be used in programs with no difference. The alias must fit to the same rules as a variable name.

Attributes of a variable

Physical I/Os are marked as either "Input" or "Output". Inputs are read-only variables. For each internal variable, you can select the "Read Only".

Parameters of User Defined Function Blocks are marked as either "IN" or "OUT".