$Arr Min: Difference between revisions
m (1 revision) |
m (1 revision) |
||
Line 2: | Line 2: | ||
<span class="pageSubtitle">Find minimum value in array</span> | <span class="pageSubtitle">Find minimum value in array</span> | ||
<p class="warning">Most Sirius $functions have been deprecated in favor of Object Oriented methods. There is no direct OO equivalent for the $Arr_Min function because the OO methods emphasize the use of [[Collections]] over the use of arrays.</p> | <p class="warning">Most Sirius $functions have been deprecated in favor of Object Oriented methods. There is no direct OO equivalent for the <var>$Arr_Min</var> function because the OO methods emphasize the use of [[Collections]] over the use of arrays.</p> | ||
<var>$Arr_Min</var> can be used to find the minimum value in an array. $Arr_Min accepts two arguments and returns a numeric code. | <var>$Arr_Min</var> can be used to find the minimum value in an array. <var>$Arr_Min</var> accepts two arguments and returns a numeric code. | ||
The first argument is 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. | The first argument is 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. | ||
Line 10: | Line 10: | ||
The second argument is the highest array element number to check. This argument can be used to limit the search to the first "N" elements in an array where N is a positive integer. | The second argument is the highest array element number to check. This argument can be used to limit the search to the first "N" elements in an array where N is a positive integer. | ||
If the minimum value occurs in multiple array elements, $Arr_Min always returns the lowest array element number containing that value. | If the minimum value occurs in multiple array elements, <var>$Arr_Min</var> always returns the lowest array element number containing that value. | ||
==Syntax== | ==Syntax== | ||
<p class="syntax"><section begin="syntax" /> %RESULT = $Arr_Min (array, maxnum) | <p class="syntax"><section begin="syntax" /> %RESULT = $Arr_Min (array, maxnum) |
Revision as of 20:51, 19 October 2012
Find minimum value in array
Most Sirius $functions have been deprecated in favor of Object Oriented methods. There is no direct OO equivalent for the $Arr_Min function because the OO methods emphasize the use of Collections over the use of arrays.
$Arr_Min can be used to find the minimum value in an array. $Arr_Min accepts two arguments and returns a numeric code.
The first argument is 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.
The second argument is the highest array element number to check. This argument can be used to limit the search to the first "N" elements in an array where N is a positive integer.
If the minimum value occurs in multiple array elements, $Arr_Min always returns the lowest array element number containing that value.
Syntax
<section begin="syntax" /> %RESULT = $Arr_Min (array, maxnum) <section end="syntax" />
In the following example
%FXARRAY IS FIXED ARRAY(5) %FXARRAY(1) = 81 %FXARRAY(2) = 49 %FXARRAY(3) = 121 %FXARRAY(4) = 25 %NUM = $Arr_Min(%FXARRAY)
%NUM is set to 4.
In the following example
%STARRAY IS STRING LEN 20 ARRAY(5) %STARRAY(1) = 'HOMER' %STARRAY(2) = 'MARGE' %STARRAY(3) = 'KRUSTY' %STARRAY(4) = 'BART' %STARRAY(5) = 'SELMA' %NUM = $Arr_Min(%STARRAY, 3)
%NUM is set to 1.