$Arr Find: Difference between revisions
m (1 revision) |
m (→Examples) |
||
Line 19: | Line 19: | ||
==Examples== | ==Examples== | ||
In the following example | In the following example, %NUM is set to 3: | ||
<p class="code"> %FXARRAY IS FIXED ARRAY(5) | <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 | |||
<p class="code"> %STARRAY IS STRING LEN 20 ARRAY(6) | In the following example, %NUM is set to 5: | ||
<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> | ||
<h2>Products authorizing {{PAGENAMEE}}</h2><ul class="smallAndTightList"> | <h2>Products authorizing {{PAGENAMEE}}</h2><ul class="smallAndTightList"> | ||
<li>[[Sirius functions]]</li> | <li>[[Sirius functions]]</li> | ||
Line 51: | Line 51: | ||
<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_Find]] | [[Category:$Functions|$Arr_Find]] |
Revision as of 00:20, 26 October 2012
Find value within array
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.
$Arr_Find can be used to find an array element with a specific value. $Arr_Find accepts three arguments and returns a numeric code.
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 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.
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.
Syntax
<section begin="syntax" />%result = $Arr_Find (array, value, minNum) <section end="syntax" />
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)