beckhoff TwinCAT 2 PLC Control — 10.4.2.3 Enumeration (ENUM)

Appendix If you define a function in your project with the name CheckBounds [ } 334] , you can automatically check for out-of-range errors in arrays ! The name of the function is fixed and can only have this designation. 10.4.2.2 Pointer Variable or function block addresses are saved in pointers while a program is running. Pointer declarations have the following syntax: : POINTER TO ; A pointer can point to any data type or function block even to user-defined types. The function of the Address Operator ADR [ } 325] is to assign the address of a variable or function block to the pointer. A pointer can be dereferenced by adding the content operator "^" after the pointer identifier.

With the help of the SIZEOF [ } 324] Operator, e.g. a pointer increment can be done. A pointer is counted up byte-wise! You can get it counted up like it is usual in the C-Compiler by us- ing the instruction p=p+SIZEOF(p^);. NOTE Adress transfer After an Online Change there might be changes concerning the data on certain addresses. Please regard this in case of using pointers on addresses. Example : pt:POINTER TO INT; var_int1:INT := 5; var_int2:INT; pt := ADR(var_int1); var_int2:= pt^; (* var_int2 is now 5 *) Example 2 (Pointer increment): ptByCurrDataOffs : POINTER TO BYTE; udiAddress :

UDINT; (*--- pointer increment ---*) udiAddress := ptByCurrDataOffs; udiAddress := udiAddress + SIZEOF(ptByCurrDataOffs^); ptByCurrDataOffs := udiAddress; (* -- end of pointer increment ---*) 10.4.2.3 Enumeration (ENUM) Enumeration is a user-defined data type that is made up of a number of string constants. These constants are referred to as enumeration values. Enumeration values are recognized in all areas of the project even if they were locally declared within aPOU. It is best to create your enumerations as objects in the Object Organizer under the register card Data types. They begin with the keyword TYPE and end with END_TYPE. Syntax:

TYPE :( , , ..., );END_TYPE TwinCAT 2 PLC Control 301 Version: 1.0