AMT Help Files

Array Functions

The following functions can be used with arrays.

Name Description
SORT Sorts a 1-dimensional to 6-dimensional array, or a number of elements within such an array, in ascending or descending order. The parent structure or parent structures cannot be arrays.
If <No. of elements> is not specified, AMT uses the last filled element. An element is empty if it contains only spaces or zeroes. Any combination of spaces and zeroes is regarded as empty.
If SORT is executed on a structure, sorting is based on the value of the structure (alpha), regardless of the subfields. This particularly affects the behavior of financial and computational subfields.
Use:
<Array item>.SORT ( [<Sort order>] [, <No of elements>] )
<Array item> Array item to sort.
<Sort order> One of the following sort options:
ASC Sorts the item in ascending order.
DSC Sorts the item in descending order.
<No of elements> The number of elements to sort. When omitted, the entire array is sorted.
Note: This option cannot be used for multidimensional arrays.

Examples

Filling the array:

saa-5[1] := 'ii'
saa-5[2] := '99'
saa-5[3] := 'ee'
saa-5[4] := 'cc'
saa-5[5] := 'aa'
// the contents of saa-5[] is now 'iiggeeccaa'

The same array after an ascending sort:

saa-5.sort(asc)
// the contents is now 'aacceeggii'

The same array after a sort with a number of elements. As shown below, only the first 3 elements are sorted in ascending order:

saa-5.sort(asc, 3)
// the contents is now 'eeggii'

In a multidimensional array, only the deepest dimension is sorted, and AMT determines the number of elements each time.

Filling the array:

saa-23[1, 1] := 'dd'
saa-23[1, 2] := 'aa'
saa-23[2, 1] := 'ee'
saa-23[2, 2] := 'cc'
// the contents of saa-23[] is now 'ddaa eecc'

After sorting:

saa-23.sort (asc)
// the contents is now 'aadd ccee'
FIND Searches for <Value> in the array. For a 1-dimensional array, the result is an integer that indicates the element in the array that contains the searched <Value>.
For a multidimensional array, the result is a string that uses commas (,) to separate the indexes, for example, "3, 1, 9".
If <Value> is not found in the array, -1 is returned.
If FIND is executed on a structure, searching is based on the value of the structure (alpha), regardless of the subfields. This particularly affects the behavior of financial and computational subfields.
Use:
<FoundIndex> := <Array item>.FIND (<Value> [, <Sort order>] [, <No of elements>] ])
<FoundIndex> Variable for the result. This variable can be of type Integer or String.
<Array item> Array item to search.
<Value> Value to search for in the array.
<Sort order> One of the following options. If duplicate values are encountered, the first match is always returned.
If <Sort order> is omitted, a serial search is always executed.
ASC Executes a binary search in ascending order.
DSC Executes a binary search in descending order. If duplicate values are encountered, the first match is always returned.
<No of elements> The number of elements. AMT stops after searching the last element.
If this option is omitted, AMT searches to the last specified element.
This option cannot be used for multidimensional arrays. In that case, AMT determines the number of elements itself.

Contents