$Arr Find: Difference between revisions

From m204wiki
Jump to navigation Jump to search
mNo edit summary
Line 4: Line 4:
<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="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>


<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 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.
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.
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==
==Syntax==
<p class="syntax"><section begin="syntax" />%result = $Arr_Find (array, value, minNum)
<p class="syntax"><section begin="syntax" />%result = $Arr_Find (array, value, minNum)
<section end="syntax" /></p>
<section end="syntax" /></p>
<p>
 
</p>
<table class="syntaxTable">
<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>%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>
 
<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>
 
<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>value</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>
</table>


==Examples==
==Examples==

Revision as of 00:25, 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.

Syntax

<section begin="syntax" />%result = $Arr_Find (array, value, minNum) <section end="syntax" />

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