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. |
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: