Language basics / Arrays |
The compiler allows the .* notation to assign an array to another array with the same structure. Static array elements are copied by value (except objects and LOB members), while elements of dynamic arrays are copied by reference, even for simple data types. This means that after assigning a dynamic array with the .* notation, if you modify an element in one of the arrays, the change will be visible in the other array. You must pay attention to this behavior if you are used to the .* notation for simple records.
MAIN DEFINE a1, a2 DYNAMIC ARRAY OF RECORD key INTEGER END RECORD LET a1[1].key = 123 LET a2.* = a1.* DISPLAY a2[1].key -- shows 123 LET a2[1].key = 456 DISPLAY a1[1].key -- shows 456 END MAIN