$Arr Find: Difference between revisions
Jump to navigation
Jump to search
m (1 revision) |
m (remove Sirius) |
||
(37 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=" | <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== | |||
<p class="syntax"><span class="term">%result</span> = $Arr_Find (<span class="term">array, value, minNum</span>) | |||
</p> | |||
<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> | |||
<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>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> | ||
</ | |||
< | |||
<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"> % | In the following example, <code>%num</code> is set to 3: | ||
<p class="code">%fxarray is fixed array(5) | |||
%fxarray(1) = 2 | |||
%fxarray(2) = 3 | |||
%fxarray(3) = 5 | |||
%fxarray(4) = 8 | |||
%num= $Arr_Find(%fxarray,5) | |||
</p> | </p> | ||
In the following example | In the following example, <code>%num</code> is set to 5: | ||
<p class="code"> % | <p class="code">%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) | |||
</p> | </p> | ||
==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_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)