$Arr Min: Difference between revisions
m (1 revision) |
No edit summary |
||
(36 intermediate revisions by 3 users not shown) | |||
Line 2: | Line 2: | ||
<span class="pageSubtitle">Find minimum value in array</span> | <span class="pageSubtitle">Find minimum value in array</span> | ||
<p class=" | <p class="warn"><b>Note:</b> Many $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. <var>$Arr_Min</var> | <var>$Arr_Min</var> can be used to find the minimum value in an [[Using_variables_and_values_in_computation#.25Variable_arrays|array]]. | ||
If the minimum value occurs in multiple array elements, <var>$Arr_Min</var> always returns the lowest array element number containing that value. | |||
==Syntax== | |||
<p class="syntax"><span class="term">%result</span> = $Arr_Min (<span class="term">array, maxnum</span>) | |||
</p> | |||
<table> | |||
<tr><th>%result</th> | |||
<td>A numeric variable that is set to the array element number that contains the indicated minimum value, or it is set to a -1 if the array or <var class="term">maxnum</var> is invalid.</td></tr> | |||
<tr><th>array</th> | |||
<td>An array of string, float, or fixed values. This array must be a single dimensional array and must not be an array in an [[Images|image]].</td></tr> | |||
< | |||
< | |||
<tr><th>maxnum</th> | |||
<td>The highest array element number to check. This argument can be used to limit the search to the first <var class="term">n</var> elements in an array, where <var class="term">n</var> is a positive integer.</td></tr> | |||
</table> | |||
In the following example | ==Examples== | ||
In the following example: | |||
<p class="code"> %FXARRAY IS FIXED ARRAY(5) | <p class="code"> %FXARRAY IS FIXED ARRAY(5) | ||
Line 28: | Line 32: | ||
%NUM = $Arr_Min(%FXARRAY) | %NUM = $Arr_Min(%FXARRAY) | ||
</p> | </p> | ||
In the following example | <code>%NUM</code> is set to 4. | ||
In the following example: | |||
<p class="code"> %STARRAY IS STRING LEN 20 ARRAY(5) | <p class="code"> %STARRAY IS STRING LEN 20 ARRAY(5) | ||
Line 40: | Line 45: | ||
%NUM = $Arr_Min(%STARRAY, 3) | %NUM = $Arr_Min(%STARRAY, 3) | ||
</p> | </p> | ||
%NUM is set to 1. | |||
<code>%NUM</code> is set to 1. | |||
==Products authorizing {{PAGENAMEE}}== | |||
<ul class="smallAndTightList"> | <ul class="smallAndTightList"> | ||
<li>[[Sirius functions]]</li> | <li>[[List of $functions|Sirius functions]]</li> | ||
<li>[[Fast/Unload User Language Interface]]</li> | <li>[[Fast/Unload User Language Interface]]</li> | ||
<li>[[Janus Open Client]]</li> | <li>[[Media:JoclrNew.pdf|Janus Open Client]]</li> | ||
<li>[[Janus Open Server]]</li> | <li>[[Media:JosrvrNew.pdf|Janus Open Server]]</li> | ||
<li>[[Janus Sockets]]</li> | <li>[[Janus Sockets]]</li> | ||
<li>[[Janus Web Server]]</li> | <li>[[Janus Web Server]]</li> | ||
<li> | <li>Japanese functions</li> | ||
<li>[[Sir2000 Field Migration Facility]]</li> | <li>[[Media:SirfieldNew.pdf|Sir2000 Field Migration Facility]]</li> | ||
</ul> | </ul> | ||
[[Category:$Functions|$Arr_Min]] | [[Category:$Functions|$Arr_Min]] |
Latest revision as of 12:14, 9 January 2018
Find minimum value in array
Note: Many $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. If the minimum value occurs in multiple array elements, $Arr_Min always returns the lowest array element number containing that value.
Syntax
%result = $Arr_Min (array, maxnum)
%result | A numeric variable that is set to the array element number that contains the indicated minimum value, or it is set to a -1 if the array or maxnum 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. |
maxnum | 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. |
Examples
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.