From m204wiki
Jump to navigation Jump to search
The printable version is no longer supported and may have rendering errors. Please update your browser bookmarks and please use the default browser print function instead.

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