DO Values with Arrays of Objects
- Last UpdatedFeb 08, 2023
- 1 minute read
Imagine that we have already defined an object type EMPLOYEE which contains a member of type STRING. We create an array of EMPLOYEE objects and set the Name member of each of each object.
!MyEmployees[1] = object EMPLOYEE()
!MyEmployees[2] = object EMPLOYEE()
!MyEmployees[3] = object EMPLOYEE()
!MyEmployees[1].Name = ‘James’
!MyEmployees[2].Name = ‘Joe’
!MyEmployees[3].Name = ‘Mike’
We then wish to create a new array containing just the employees’ names.
!Names = ARRAY()
do !Person VALUES !MyEmployees
!Names.Append(!Person.Name)
enddo
Each time round the do-loop, the do-variable becomes an object of the appropriate type, even if the array is a heterogeneous mixture of objects.