$Arr Max: Difference between revisions

From m204wiki
Jump to navigation Jump to search
(Automatically generated page update)
m (misc formatting)
 
(8 intermediate revisions by 2 users not shown)
Line 2: Line 2:
<span class="pageSubtitle">Find maximum value in array</span>
<span class="pageSubtitle">Find maximum value in array</span>


<p class="warn"><b>Note: </b>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="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_Max</var> 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> can be used to find the maximum value in an [[Using variables and values in computation#.25Variable arrays|array]].  


==Syntax==
==Syntax==
<p class="syntax"><span class="term">%result</span> = $Arr_Max (array, maxnum)
<p class="syntax"><span class="term">%result</span> = $Arr_Max (<span class="term">array, maxnum</span>)
</p>
</p>


<p><var class="term">%result</var> indicates the element number of the maximum value in the array, or indicates a -1 if array or maxnum is invalid.</p>
<table>
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.
<tr><th>%result</th>
<td>A numeric variable that is set to the array element number that contains the indicated maximum value, or it is set to a -1 if the array or <var class="term">maxnum</var> is invalid.</td></tr>


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.  
<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>


==Usage notes==
==Usage notes==
Line 22: Line 28:
==Examples==
==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)
%FXARRAY(1) = 81
%FXARRAY(1) = 81
%FXARRAY(2) = 49
%FXARRAY(2) = 49
%FXARRAY(3) = 121
%FXARRAY(3) = 121
%FXARRAY(4) = 25
%FXARRAY(4) = 25
%NUM = $Arr_Max(%FXARRAY)
%NUM = $Arr_Max(%FXARRAY)
</p>
</p>
%NUM is set to 3.  
 
<code>%NUM</code> is set to 3.  


In the following example
In the following example
<p class="code"> %STARRAY IS STRING LEN 20 ARRAY(5)
<p class="code">%STARRAY IS STRING LEN 20 ARRAY(5)  
%STARRAY(1) = 'HOMER'
%STARRAY(1) = 'HOMER'
%STARRAY(2) = 'MARGE'
%STARRAY(2) = 'MARGE'
%STARRAY(3) = 'BART'
%STARRAY(3) = 'BART'
%STARRAY(4) = 'KRUSTY'
%STARRAY(4) = 'KRUSTY'
%STARRAY(5) = 'SELMA'
%STARRAY(5) = 'SELMA'
%NUM = $Arr_Max(%STARRAY, 4)
%NUM = $Arr_Max(%STARRAY, 4)
</p>
</p>
%NUM is set to 2.<p>
 
<code>%NUM</code> is set to 2.<p>


==Products authorizing {{PAGENAMEE}}==  
==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>[http://m204wiki.rocketsoftware.com/images/4/4a/JoclrNew.pdf Janus Open Client]</li>
<li>[[Media:JoclrNew.pdf|Janus Open Client]]</li>
<li>[http://m204wiki.rocketsoftware.com/images/1/17/JosrvrNew.pdf 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>Japanese functions</li>
<li>Japanese functions</li>
<li>[http://m204wiki.rocketsoftware.com/images/4/4b/SirfieldNew.pdf Sir2000 Field Migration Facility]</li>
<li>[[Media:SirfieldNew.pdf|Sir2000 Field Migration Facility]]</li>
</ul>
</ul>


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

Latest revision as of 20:21, 8 January 2018

Find maximum value in array

Note: Many $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

%result = $Arr_Max (array, maxnum)

%result A numeric variable that is set to the array element number that contains the indicated maximum 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.

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