- Accessing members of structures
- Indirect members of structures
- dynamic lookup by name
- dynamic lookup by position
- Arrays of structures and structures as elements of arrays
- Multiple references to the same structure
- Assigning runtime space for structures (creating a structure)
- Adding members to a structure
- Adding a structure as a member
- Adding an array as a member
- Creating a copy of a structure
Accessing members of structures
a.b a.b.cindirect members of structures
(dynamic lookup by name)foo = "b" a[foo]indirect members of structures
(dynamic lookup by position)foo = 5 a[foo]arrays of structures and structures as elements of arrays
Multiple references to the same structure
This is equivalent to a 'C' pointer to structure.
t1 = ref(s) t2 = ref(t1)There is no '->' operator in XPE. To access a member of a shared structure (structure with multiple references) use the '.' operator in exactly the same way as for a non-shared structure.To obtain a uniqe copy of a shared structure use the 'value' function. However beware that a structure that has an embedded reference to itself cannot be completely copied as it will still have references to the original structure embedded in it.
e.g.
t3 = value(t2)Assigning runtime space for structures (creating a structure)
s = struct()s.x = 0 s.y = 0 s.z = 0adding a structure as a member
s.x = struct()s.x = array(N)creating a copy of a structure
r = sto use a member of this new structure simply use it as you would in 'C'. Beware however that you cannot read a value from a member if it has not first been initialised
see also
external interface to