3 enumeration type, Enumeration type, Drive plc developer studio – Lenze DDS v2.3 User Manual
Page 261

Drive PLC Developer Studio
IEC 61131-3 Data types
10-5
l
DDS EN 2.3
Pointer declarations have the following syntax:
A pointer can point to any data type or function block, including user-defined function blocks.
Use address operator ADR to assign a variable or function block address to the pointer.
Pointers are de-referenced via the contents operator ^ behind the pointer identifier.
Example:
Declaration
pt:POINTER TO INT;
var_int1:INT := 5;
var_int2:INT;
Implementation
pt := ADR(var_int1);
var_int2:= pt^; (* var_int2 is now 5 *)
10.2.3
Enumeration type
An enumeration type is a user-defined data type that consists of several string constants. These
constants are referred to as enumeration values.
Enumeration values are known throughout the entire project even if they were locally declared in an
organization unit. They are best created as objects in the
Object Organizer on the index card Data
types. They start with the keyword TYPE and end with END_TYPE.
Syntax:
TYPE
END_TYPE
The values are compatible with integers, i.e. operations can be carried out as with INT. A number
x may be assigned to the
not initialized, counting starts at 0. Each enumeration takes up 1 byte of memory.
Ensure when initializing that the initial values are in ascending order. The validity of the number is
checked at runtime.
Example:
TYPE
TRAFFICLIGHT: (red, yellow, green:=10);
(* red has the initial value 0, yellow 1, green 10 *)
END_TYPE
Declaration
TRAFFICLIGHT1:TRAFFICLIGHT:=0; (* TRAFFICLIGHT1 has the value red *)
Implementation
IF
TRAFFICLIGHT = red THEN
TRAFFICLIGHT := GREEN;
END_IF
Show/Hide Bookmarks