Skip to main content

Structure (STRUCT)

A STRUCT is a user-defined data type that groups together different types of variables under a single name. This enable the user to create more complex data types that can represent real world objects.

Syntax

TYPE <TypeName> :
STRUCT
// A list of members
END_STRUCT
END_TYPE
TYPE ST_Type :
STRUCT
a : INT;
b : BOOL;
c : ARRAY[1..3] OF STRING;
d : REAL;
END_STRUCT
END_TYPE

Inheritance

A STRUCT Type can EXTEND another STRUCT Type effectively combining the members of one type with another. This can be useful when additional fields are required.

TYPE ST_Base :
STRUCT
a : INT;
END_STRUCT
END_TYPE

TYPE ST_Type EXTENDS ST_Base :
STRUCT
b : BOOL;
END_STRUCT
END_TYPE

VAR
inst : ST_Type;
END_VAR

inst.a := 5;
inst.b := FALSE;