From m204wiki
Revision as of 16:10, 8 January 2018 by JAL (talk | contribs) (remove Sirius)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Find value within array

Note: Many $functions have been deprecated in favor of Object Oriented methods. There is no direct OO equivalent for $Arr_Find, because the OO methods emphasize the use of Collections over the use of arrays.

$Arr_Find can be used to find an array element with a specific value.


%result = $Arr_Find (array, value, minNum)

%result A numeric variable that is set to the array element number that contains the indicated value, or it is set to a -1 if the value was not found or if the array or minNum is invalid.
array An array of string, float, or fixed values. This array must be a single dimensional array and must not be an array in an image.
value The value to be located in the array. If this value is found in multiple array elements, $Arr_Find always returns the first (lowest element number) array element containing this value.
minNum The lowest array element number to check. This argument can be used to skip the first n array elements, where n is a positive integer.


In the following example, %num is set to 3:

%fxarray is fixed array(5) %fxarray(1) = 2 %fxarray(2) = 3 %fxarray(3) = 5 %fxarray(4) = 8 %num= $Arr_Find(%fxarray,5)

In the following example, %num is set to 5:

%starray is string len 20 array(6) %starray(1) = 'ONE' %starray(2) = 'TWO' %starray(3) = 'THREE' %starray(4) = 'FOUR' %starray(5) = 'ONE' %starray(6) = 'TWO' %num = $Arr_Find(%starray, 'ONE', 2)

Products authorizing $Arr_Find