$Arr Max: Difference between revisions

From m204wiki
Jump to navigation Jump to search
m (1 revision)
mNo edit summary
Line 4: Line 4:
<p class="warning">Most Sirius $functions have been deprecated in favor of Object Oriented methods. There is no direct OO equivalent for the $Arr_Max 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 $Arr_Max function because the OO methods emphasize the use of [[Collections]] over the use of arrays.</p>


<var>$Arr_Max</var> can be used to find the maximum value in an array. <var>$Arr_Max</var> accepts two arguments and returns a numeric code.  
<var>$Arr_Max</var> can be used to find the maximum value in an array.  


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 maximum value occurs in multiple array elements, <var>$Arr_Max</var> always returns the lowest array element number containing that value.
==Syntax==
==Syntax==
<p class="syntax"><section begin="syntax" />%result = $Arr_Max (array, maxnum)
<p class="syntax"><section begin="syntax" />%result = $Arr_Max (array, maxnum)
<section end="syntax" /></p>
<section end="syntax" /></p>
<p>
 
</p>
<p class="caption">%result indicates the element number of the maximum value in the array, or indicates a -1 if array or maxnum is invalid.</p>
<p class="caption">%result indicates the element number of the maximum value in the array, or indicates a -1 if array or maxnum is invalid.</p>
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.


==Usage notes==
<ul>
<li>If the maximum value occurs in multiple array elements, <var>$Arr_Max</var> always returns the lowest array element number containing that value.
</ul>


==Examples==
In the following example
In the following example
<p class="code"> %FXARRAY IS FIXED ARRAY(5)
<p class="code"> %FXARRAY IS FIXED ARRAY(5)
Line 42: Line 44:
%NUM is set to 2.<p>
%NUM is set to 2.<p>


<h2>Products authorizing {{PAGENAMEE}}</h2><ul class="smallAndTightList">
<h2>Products authorizing {{PAGENAMEE}}</h2>
<ul class="smallAndTightList">
<li>[[Sirius functions]]</li>
<li>[[Sirius functions]]</li>
<li>[[Fast/Unload User Language Interface]]</li>
<li>[[Fast/Unload User Language Interface]]</li>
Line 51: Line 54:
<li>[[Japanese functions]]</li>
<li>[[Japanese functions]]</li>
<li>[[Sir2000 Field Migration Facility]]</li>
<li>[[Sir2000 Field Migration Facility]]</li>
</ul>
</ul>
   
   


[[Category:$Functions|$Arr_Max]]
[[Category:$Functions|$Arr_Max]]

Revision as of 00:34, 26 October 2012

Find maximum value in array

Most Sirius $functions have been deprecated in favor of Object Oriented methods. There is no direct OO equivalent for the $Arr_Max function because the OO methods emphasize the use of Collections over the use of arrays.

$Arr_Max can be used to find the maximum value in an array.

Syntax

<section begin="syntax" />%result = $Arr_Max (array, maxnum) <section end="syntax" />

%result indicates the element number of the maximum value in the array, or indicates a -1 if array or maxnum is invalid.

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.

Usage notes

  • If the maximum value occurs in multiple array elements, $Arr_Max always returns the lowest array element number containing that value.

Examples

In the following example

%FXARRAY IS FIXED ARRAY(5) %FXARRAY(1) = 81 %FXARRAY(2) = 49 %FXARRAY(3) = 121 %FXARRAY(4) = 25 %NUM = $Arr_Max(%FXARRAY)

%NUM is set to 3.

In the following example

%STARRAY IS STRING LEN 20 ARRAY(5) %STARRAY(1) = 'HOMER' %STARRAY(2) = 'MARGE' %STARRAY(3) = 'BART' %STARRAY(4) = 'KRUSTY' %STARRAY(5) = 'SELMA' %NUM = $Arr_Max(%STARRAY, 4)

%NUM is set to 2.

Products authorizing $Arr_Max