Find and FindUp (Stringlist functions): Difference between revisions

From m204wiki
Jump to navigation Jump to search
m (1 revision)
m (syntax digram, tags and links)
Line 3: Line 3:
{{Template:Stringlist:FindUp subtitle}}
{{Template:Stringlist:FindUp subtitle}}


These methods locate a <var>Stringlist</var> item that exactly matches a specified string. The difference between Find and FindUp is the direction of the search: Find searches from the starting point in ascending item number order, while FindUp searches in descending item number order. The Find and FindUp methods return the item number of the <var>Stringlist</var> item that matches the input string, or they return an error code.
Both these methods locate a <var>Stringlist</var> item that exactly matches a specified <var class="term">string</var>. The difference between <var>Find</var> and <var>FindUp</var> is the direction of the search: <var>Find</var> searches from the starting point in ascending item number order, while <var>FindUp</var> searches in descending item number order.
 
Both <var>Find</var> and <var>FindUp</var> return the item number of the <var>Stringlist</var> item that matches the input <var class="term">string</var>, or they return an error code.


==Syntax==
==Syntax==
Line 10: Line 12:
===Syntax terms===
===Syntax terms===
<table class="syntaxTable">
<table class="syntaxTable">
<tr><th>%rc </th>
<tr><th>%number </th>
<td>A numeric variable that is set to the number of the first item in the <var>Stringlist</var> that matches the search string, or it is set to 0 if the string is not found. </td></tr>
<td>A numeric variable that is set to the number of the first item in the <var>Stringlist</var> that matches the search <var class="term">string</var>, or it is set to 0 if the string is not found. </td></tr>
<tr><th>sl </th>
<tr><th>sl </th>
<td>A <var>Stringlist</var> object. </td></tr>
<td>A <var>Stringlist</var> object. </td></tr>
<tr><th>string </th>
<tr><th>string </th>
<td>The string to be matched. This is a required argument. </td></tr>
<td>The <var class="term">string</var> to be matched. This is a required argument. </td></tr>
<tr><th>startitem </th>
<tr><th>startitem </th>
<td>A number that indicates the item number at which the search is to begin. If this argument is not specified, searching begins at the first item in the <var>Stringlist</var> for Find, and at the last item for FindUp. Not specifying the starting item number is subtly different from specifying a starting item number of 1 -- the latter is an error if the <var>Stringlist</var> is empty, while the former simply returns a 0.</td></tr>
<td>A number that indicates the item number at which the search is to begin. If this argument is not specified, searching begins at the first item in the <var>Stringlist</var> for <var>Find</var>, and at the last item for <var>FindUp</var>. Not specifying the starting item number is subtly different from specifying a starting item number of 1 -- the latter is an error if the <var>Stringlist</var> is empty, while the former simply returns a 0.</td></tr>
</table>
</table>


==Usage Notes==
==Usage Notes==
<ul>
<ul>
<li>A return code of 0 from the Find or FindUp method indicates that the string was not found. All other errors result in request cancellation.
<li>A return code of 0 from <var>Find</var> or <var>FindUp</var> indicates that the string was not found. All other errors result in request cancellation.
<li>The difference between Find/FindUp and the [[Locate (Stringlist function)]] and [[LocateUp (Stringlist function)]] is that when Find or FindUp is used, a <var>Stringlist</var> item must match the search string exactly rather than simply contain the search string. Moreover, Find and FindUp do not allow specification of a range of columns (or positions) that are to be searched.<li>The FindUp method is available in <var class=product>Sirius Mods</var> Version 6.9 and later.
<li>The difference between <var>Find</var>/<var>FindUp</var> and the <var>[[Locate (Stringlist function)|Locate]]</var> and <var>[[LocateUp (Stringlist function)|LocateUp]]</var> is that when <var>Find</var> or <var>FindUp</var> are used, a <var>Stringlist</var> item must match the search <var class="term">string</var> exactly rather than simply contain the search string. Moreover, <var>Find</var> and <var>FindUp</var> do not allow specification of a range of columns (or positions) that are to be searched.<li>The <var>FindUp</var> method is available in <var class="product">Sirius Mods</var> Version 6.9 and later.
</ul>
</ul>


[[Category:Stringlist methods|Find/FindUp function]]
[[Category:Stringlist methods|Find/FindUp function]]

Revision as of 02:17, 26 January 2011

Template:Stringlist:Find subtitle

Template:Stringlist:FindUp subtitle

Both these methods locate a Stringlist item that exactly matches a specified string. The difference between Find and FindUp is the direction of the search: Find searches from the starting point in ascending item number order, while FindUp searches in descending item number order.

Both Find and FindUp return the item number of the Stringlist item that matches the input string, or they return an error code.

Syntax

%number = sl:Find( string, [startItem])

%number = sl:FindUp( string, [startItem])

Syntax terms

%number A numeric variable that is set to the number of the first item in the Stringlist that matches the search string, or it is set to 0 if the string is not found.
sl A Stringlist object.
string The string to be matched. This is a required argument.
startitem A number that indicates the item number at which the search is to begin. If this argument is not specified, searching begins at the first item in the Stringlist for Find, and at the last item for FindUp. Not specifying the starting item number is subtly different from specifying a starting item number of 1 -- the latter is an error if the Stringlist is empty, while the former simply returns a 0.

Usage Notes

  • A return code of 0 from Find or FindUp indicates that the string was not found. All other errors result in request cancellation.
  • The difference between Find/FindUp and the Locate and LocateUp is that when Find or FindUp are used, a Stringlist item must match the search string exactly rather than simply contain the search string. Moreover, Find and FindUp do not allow specification of a range of columns (or positions) that are to be searched.
  • The FindUp method is available in Sirius Mods Version 6.9 and later.