Types

<< Click to Display Table of Contents >>

Navigation:  »No topics above this level«

Types

mapp Services V5.16

Section for type declaration

Customized data types can be declared in TYPE declaration sections.

Syntax

TYPE [ { <Scope> } ]
  // Type declarations
END_TYPE

Reference framework parameters

NC_GLOBAL: Type visible across all interpreter instances, e.g. all axis groups

IP_GLOBAL: Type visible within the interpreter instance, e.g. one axis group

LOCAL: Type visible within the file

The default scope of declared types is determined according to the file extension and the most recent #pragma SCOPE.

Declared types can only be used for data and functions declared within the same or a local scope.

NC_GLOBAL types remain in memory until the PLC restarts, even if the file containing their declarations is unloaded (e.g. using command UNLOAD).

Loading type declaration files

Type declaration files (.TYP) can be started as regular programs (e.g. using MC_BR_MoveProgram) that only perform loading. Alternatively, they can be loaded using directive #pragma LOAD or #include.

Example

#include 'defs.typ'
VAR {AT PLC}
  Context : AppContextType;  (* AppContextType defined in defs.typ *)
END_VAR

Default initial value

Initial values can be specified in a type declaration. The initial value is used when a variable of that type is created.

If a type defines minimum and maximum values, the minimum value will be applied as the initial value of a variable.

Example

TYPE
  Array5Type : ARRAY[0..4] OF DINT := [1, 2, 3, 4, 5];
  RangeType : DINT (-100..100);
END_TYPE
VAR
  A: Array5Type; (* A initialized to [1, 2, 3, 4, 5] *)
  R: RangeType;  (* R initialized to -100 *)
END_VAR

Topics in this section:

Section for type declaration

Loading type declaration files

Default initial value

Referencing types

Enumerated types

Nested array types