Nested Data Structure members can also be defined inline in a Data Structure. These inline definitions define a member but cannot be used to define Data Structure variables. To declare an inline Data Structure the definition can be placed directly within the statement DATASTRUCTURE wherever a member could be defined:
DATASTRUCTURE Member BEGIN ... END
ARRAY DATASTRUCTURE Member [0] BEGIN ... END
MAP DATASTRUCTURE Member BEGIN ... END
Inline Data Structure member definitions can also be nested within another inline definition:
Example
DATASTRUCTURE Array2d
BEGIN
ARRAY DATASTRUCTURE D [0]
BEGIN
ARRAY DATASTRUCTURE D [0]
BEGIN
TEXT T
END
END
END
The example above defines a Data Structure type Array2d that functions as a 2-dimensional array. The dimensions are implemented using the D-member arrays, the content is accessed in the T-member:
DECLARE my_grid DEFINED_AS Array2d
ASSIGN my_grid.D[4].D[8].T := "This is element[4][8]"
The inline Data Structure members function identically to Data Structure variables, but they can only be copied between variables of their parent Data Structure type.
Examples
SET my_grid.D[1] -> NEW my_grid.D[18] (* OK - copy *)
SET my_grid.D[2] -> reference_grid.D[1024] (* OK - reference *)
SET my_grid.D[3] -> my_grid.D[11].D[4] (* Different definitions: not allowed *)
Inline DATASTRUCTURE definitions can be used as types by specifying the path to the definition.
Example
DATASTRUCTURE Example
BEGIN
DATASTRUCTURE One
BEGIN
DATASTRUCTURE Two
BEGIN
TEXT T
END
END
Example.One AnotherOne
Example.One.Two AnotherTwo
END
DECLARE full_struct DEFINED_AS Example
DECLARE two_sub_struct DEFINED_AS Example.One.Two
SET full_struct.One.Two -> two_sub_struct
In this example the member AnotherOne has the same structure as the member One, including the member Two. The member AnotherTwo is a copy of the member's structure Two.