Variables
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 |
%I... |
Channels of an input board.
|
%Q... |
Channels of an output board.
|
GLOBAL |
Internal variables known by all programs. |
PROGRAMxxx |
All internal variables local to a program. The name of the group is the name of the program. |
Non volatile internal variables known by all programs.
|
|
UDFBxxx |
|
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 a function block, 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 block or to a User Defined Function Block.
If the selected data type is STRING, you must specify a maximum length.
This cannot exceed 255 characters.
- See the list of Data Types.
- See Call a Function Block about using a function instance.
- Specify dimensions 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.
Variable Attributes
Physical I/Os are marked as either Input or Output.
- Each internal variable can be configured as Read / Write or Read-only.
- See Attributes.
- Read-only variables can be mapped to Outputs but not to Inputs.
- Inputs can change state and a Read-only variable cannot change its value to match the input state.
- See Attributes.
- Parameters of User-Defined Function Blocks are marked as either INor OUT.