$Arr Find: Difference between revisions

From m204wiki
Jump to navigation Jump to search
m (1 revision)
m (remove Sirius)
 
(29 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> accepts three arguments and returns a numeric code.  
<var>$Arr_Find</var> can be used to find an [[Using variables and values in computation#%Variable arrays|array]] element with a specific value.  


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.
==Syntax==
<p class="syntax"><span class="term">%result</span> = $Arr_Find (<span class="term">array, value, minNum</span>)
</p>


The second argument is 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.  
<table class="syntaxTable">
<tr><th>%result</th>
<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>


The third argument is 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.
<tr><th>array</th>
==Syntax==
<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>  
<p class="syntax"><section begin="syntax" />%result = $Arr_Find (array, value, minNum)
 
<section end="syntax" /></p>
<tr><th>value</th>
<p class="caption">$Arr_Find Function
<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>  
</p>
<p class="caption">%result 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.</p>


<tr><th>minNum</th>
<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>


In the following example
==Examples==
<p class="code"> %FXARRAY IS FIXED ARRAY(5)
In the following example, <code>%num</code> is set to 3:
<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>
%NUM is set to 3.


In the following example
In the following example, <code>%num</code> 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(1) = 'ONE'
%starray(2) = 'TWO'
%STARRAY(2) = 'TWO'
%starray(3) = 'THREE'
%STARRAY(3) = 'THREE'
%starray(4) = 'FOUR'
%STARRAY(4) = 'FOUR'
%starray(5) = 'ONE'
%STARRAY(5) = 'ONE'
%starray(6) = 'TWO'
%STARRAY(6) = 'TWO'
%num = $Arr_Find(%starray, 'ONE', 2)
%NUM = $Arr_Find(%STARRAY, 'ONE', 2)
</p>
</p>
%NUM is set to 5.
 
==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>[[Japanese functions]]</li>
<li>Japanese functions</li>
<li>[[Sir2000 Field Migration Facility]]</li>
<li>[[Media:SirfieldNew.pdf|Sir2000 Field Migration Facility]]</li>
 
</ul>
</ul>
<p class="caption">Products authorizing $Arr_Find
</p>


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