Variables

All variables used in programs must be declared first in the variable editor.

Each variable belongs to a group and must be identified by a unique name in its group.

Groups

A group is a set of variables.

A group refers to a physical class of variables or identifies the variables local to a program or user-defined function block.

This table lists the possible groups:

Groups Description

GLOBAL

Internal variables known by all programs.

Retain Variables

Non volatile internal variables known by all programs.

%I...

Channels of an input board.

Variables with same data type are linked to a physical input device.

%Q...

Channels of an output board.

Variables with same data type are 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 BlockClosed A function block groups an algorithm and a set of private data. It has inputs and outputs. 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.

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

  • See the list of Data Types for more information.
  • See Call a Function Block for more information about using a function instance.
  • Specify dimension(s) for an internal variable, to declare Arrays.

Name 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.
    • have the same name as a standard or C function or function block.
    • See the List of C Functions webpage.
  • A variable must not have the same name as a program or a user-defined function block.
  • The name of a variable must begin by a letter or an underscore (_), followed by letters, digits, or underscore marks.
    • Two consecutive underscores in a variable name is not allowed.
  • Naming is case-insensitive.
    • Two names with different cases are considered as the same.

Attributes of a Variable

Physical I/Os are marked as either Input or Output.

  • Each internal variable can be configured as Read/Write or Read Only.
    • Read Only variables can be mapped to Outputs, but not to Inputs.
    • This is because Inputs can change state and a Read Only variable would not be able to change its value to match the input state.
  • Parameters of User-Defined Function Blocks are marked as either INor OUT.