Declaration of a data type in ST

Syntax
TYPE
name1 : <data type declarations with optional initialization>;
name2 : <data type declarations with optional initialization>;
...
END_TYPE

Meaning

declaration of →user-defined data types, name1 etc. must be →IEC-identifiers.
The declaration is possible within an ST-object – the declaration is done either within the global →namespace or within a declared namespace. TYPE and END_TYPE are →keywords for the declaration of user-defined data types. After name : enter the declarations for the data type itself. See the following articles, if you need information about the declaration and the access:

You will find the following examples in the descriptions of the corresponding data type as well. Those descriptions explain these examples in more details and list even more examples.

Example
TYPE 
TrafficLight : INT (Red := 1, Yellow:= 2, Green := 3); (* data type with named values *)
myType: ARRAY [1..9] OF INT := [1, 2, 3]; (* array data type, base type = 'INT' *)
RangeS : STRUCT (* structured data type *)
signal : BOOL;
scaleMin : DINT;
scaleMax : DINT;
END_STRUCT;
 
typeScalings : ARRAY [1..5] OF myINT := [2(3), 2(), 4]; (* array data type, base type = 'myINT' *)
RangeConf : RangeS := (scaleMin := -5, scaleMax := 5); (* derived data type, base type = 'RangeS' *)
 
myINT : INT := 5; (* derived data type, base type = 'INT' *)
END_TYPE

Moreover, you are able to use the following language elements for ST when declaring a data type: