Array Methods
- Last UpdatedJan 28, 2025
- 1 minute read
Note:
The Software Customization Reference documentation contains a list of all PML methods.
Array methods are built-in functions for performing a variety of operations on the array. These methods are invoked with a dot following the array name. The method name must be followed by ( ) parentheses - even if the function has no arguments:
!Nelements = !MyArray.Size()
This method sets !Nelements to the number of elements currently in the array. This is an example of a no-effect method which does not alter the array but returns a REAL result which can be assigned to another variable.
Here is method which does change the array:
!MyArray.Clear()
This is an example of a method which modifies the array by deleting all the array elements but produces no-result value, so there is nothing to assign to another variable.
There is a third kind of method which both changes the array and returns a result value. Here, the result is assigned to a variable:
!NewArray = !OldArray.RemoveFrom(5,10)
This is an example of a method result which modifies the array by removing 10 elements, starting at element 5. NewArray value is a new array containing the 10 removed elements.
If not required, the result can be simply discarded by invoking the method as a command and not assigning the result to a variable:
!OldArray.RemoveFrom(5,10)
Note:
Always use an array method, if one is available, in preference to constructing a do-loop
as it is far more efficient.