Find and FindUp (Stringlist functions): Difference between revisions
Jump to navigation
Jump to search
m (better tagging) |
m (argh, another tag) |
||
Line 11: | Line 11: | ||
<table class="syntaxTable"> | <table class="syntaxTable"> | ||
<tr><th>%number </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 <var class="term">string</var>, 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 search <var class="term">string</var> 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> |
Revision as of 01:42, 27 January 2011
Find next/previous Stringlist item that exactly matches a string (Stringlist class)
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 search 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 Locate / LocateUp is that when Find or FindUp are used, a Stringlist item must exactly match the search string rather than simply containing the search string. Moreover, Find and FindUp do not allow specification of a range of columns (or positions) that are to be searched.
- FindUp is available in Sirius Mods Version 6.9 and later.