$Arr Find: Difference between revisions

From m204wiki
Jump to navigation Jump to search
mNo edit summary
m (remove Sirius)
 
(19 intermediate revisions by 4 users not shown)
Line 2: Line 2:
<span class="pageSubtitle">Find value within array</span>
<span class="pageSubtitle">Find value within 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_Find 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 <var>$Arr_Find</var>, because the OO methods emphasize the use of [[Collections]] over the use of arrays.</p>


<var>$Arr_Find</var> can be used to find an array element with a specific value.  
<var>$Arr_Find</var> can be used to find an [[Using variables and values in computation#%Variable arrays|array]] element with a specific value.  


==Syntax==
==Syntax==
<p class="syntax"><section begin="syntax" />%result = $Arr_Find (array, value, minNum)
<p class="syntax"><span class="term">%result</span> = $Arr_Find (<span class="term">array, value, minNum</span>)
<section end="syntax" /></p>
</p>


<table class="syntaxTable">
<table class="syntaxTable">
<tr><th>%result</th>
<tr><th>%result</th>
<td>A numeric variable that is set to the array element number containing the indicated value, or it is set to a -1 if the value was not found or if the array or <var class="term">minNum</var> is invalid.</td></tr>
<td>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 <var class="term">minNum</var> is invalid.</td></tr>


<tr><th>array</th>
<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 image.</td></tr>  
<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>value</th>
<tr><th>value</th>
<td>The value to be located in the array. If this value is found in multiple array elements, <var>$Arr_Find</var> always returns the first (lowest element number) array element containing this value. </td></tr>  
<td>The value to be located in the array. If this value is found in multiple array elements, <var>$Arr_Find</var> always returns the first (lowest element number) array element containing this value. </td></tr>  


<tr><th>value</th>
<tr><th>minNum</th>
<td>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.</td></tr>  
<td>The lowest array element number to check. This argument can be used to skip the first <var class="term">n</var> array elements, where <var class="term">n</var> is a positive integer.</td></tr>  
</table>
</table>


==Examples==
==Examples==
In the following example, %NUM is set to 3:
In the following example, <code>%num</code> is set to 3:
<p class="code">%FXARRAY IS FIXED ARRAY(5)
<p class="code">%fxarray is fixed array(5)
%fxarray(1) = 2
%FXARRAY(1) = 2
%fxarray(2) = 3
%FXARRAY(2) = 3
%fxarray(3) = 5
%FXARRAY(3) = 5
%fxarray(4) = 8
%FXARRAY(4) = 8
%num= $Arr_Find(%fxarray,5)
%NUM = $Arr_Find(%FXARRAY,5)
</p>
</p>


 
In the following example, <code>%num</code> is set to 5:  
In the following example, %NUM is set to 5:  
<p class="code">%starray is string len 20 array(6)
<p class="code">%STARRAY IS STRING LEN 20 ARRAY(6)
%starray(1) = 'ONE'
%starray(2) = 'TWO'
%STARRAY(1) = 'ONE'
%starray(3) = 'THREE'
%STARRAY(2) = 'TWO'
%starray(4) = 'FOUR'
%STARRAY(3) = 'THREE'
%starray(5) = 'ONE'
%STARRAY(4) = 'FOUR'
%starray(6) = 'TWO'
%STARRAY(5) = 'ONE'
%num = $Arr_Find(%starray, 'ONE', 2)
%STARRAY(6) = 'TWO'
%NUM = $Arr_Find(%STARRAY, 'ONE', 2)
</p>
</p>


<h2>Products authorizing {{PAGENAMEE}}</h2><ul class="smallAndTightList">
==Products authorizing {{PAGENAMEE}}==
<li>[[Sirius functions]]</li>
<ul class="smallAndTightList">
<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>[[Japanese functions]]</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_Find]]
[[Category:$Functions|$Arr_Find]]

Latest revision as of 16:10, 8 January 2018

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.

Syntax

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

Examples

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