AMT Help Files

Array Functions

The following functions can be used for arrays.

Name Description 
SORT

Sorts a 1 to 6 dimensional array or a number of within such an array in ascending or descending order.

The parent structure(s) may not be arrays.

If <No. of elements> is not specified, AMT will take the last filled element.

An element is empty if these only contain spaces or zeroes. Any combination of spaces and zeroes is regarded as empty.

If a SORT is executed on a structure, then the sorting will be based on the value in the structure (alpha), disregarding the sub fields. This particularly influences the behavior for financial and computational subfields.

Use:    
<Array item>.SORT ( [<Sort order>] [, <No of elements>] )
<Array item> Array item to be sorted
<Sort order> One of the following sort options:
  ASC Makes that the item is sorted ascending.
  DSC Makes that the item is sorted descending.
<No of elements> The number of elements to be sorted. When omitted the entire array will be sorted.
Note: This option can NOT 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 a sort ascending:

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

The same array after a sort with no. of elements. As you can see it only sorted the first 3 elements in ascending order:

saa-5.sort(asc3)
// the contents is now 'eeggii'

In a multi dimensional array, only the deepest dimension will be sorted and AMT will search every time for the number of elements.

Filling the array:

saa-23[11] := 'dd'
saa-23[12] := 'aa'
saa-23[21] := 'ee'
saa-23[22] := 'cc'
// the contents of saa-23[] is now 'ddaa  eecc'

After sorting:

saa-23.sort (asc)
// the contents is now 'aadd  ccee'

FIND

Searches the <Value> in the array. If a 1 dimensional array is concerned, then the result will be an integer, indicating the element within the array that holds the searched <Value>.

If a multi dimensional array is concerned, then the result will be a string using a comma (,) for separating the indexes (e.g. "3, 1, 9").

When <Value> is not found in the array -1 will be returned.

If a FIND is executed on a structure, then the sorting will be based on the value in the structure (alpha), disregarding the sub fields. This particularly influences the behavior for financial and computational subfields.

Use: 
<FoundIndex> := <Array item>.FIND (<Value> [, <Sort order>] [, <No of elements>] ])
<FoundIndex> Variable for the result. Either of type Integer or String. 
<Array item> Array item to be sorted.
<Value> Value to be searched for in the Array.
<Sort order> One of the options that is specified below. If double values are encountered, always the first will be returned.

If the <Sort order> is omitted always a serial search will be executed.
  ASC Makes that a binary search is executed in ascending order.
  DSC Makes that a binary search is executed in descending order. If double values are encountered, always the first will be returned.
<No of elements> The number of elements. AMT stops after searching the last element.

If this option is omitted, AMT will search the last specified element.

This option can not be used for multidimensional arrays. In that case, AMT will determine the number of elements itself.