Find and FindUp (Stringlist functions): Difference between revisions

From m204wiki
Jump to navigation Jump to search
mNo edit summary
mNo edit summary
Line 11: Line 11:
{{Template:Stringlist:FindUp syntax}}
{{Template:Stringlist:FindUp syntax}}
===Syntax terms===
===Syntax terms===
<dl>
<table class="syntaxTable">
<dt>%rc
<tr><th>%rc </th>
<dd>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.
<td>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. </td></tr>
<dt>%sl
<tr><th>sl </th>
<dd>A Stringlist object.
<td>A Stringlist object. </td></tr>
<dt>string
<tr><th>string </th>
<dd>The string to be matched. This is a required argument.
<td>The string to be matched. This is a required argument. </td></tr>
<dt>startitem
<tr><th>startitem </th>
<dd>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.  
<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 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.</td></tr>
</dl>
</table>


==Usage Notes==
==Usage Notes==

Revision as of 23:22, 16 January 2011

Template:Stringlist:Find subtitle

Template:Stringlist:FindUp subtitle

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. The Find and FindUp methods return the item number of the Stringlist item that matches the input string, or they return an error code.

Find and FindUp are members of the Stringlist class.

Syntax

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

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

Syntax terms

%rc 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 the Find or FindUp method indicates that the string was not found. All other errors result in request cancellation.
  • The difference between Find/FindUp and the Locate (Stringlist function) and LocateUp (Stringlist function) is that when Find or FindUp is 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.