LocateUp (Stringlist function): Difference between revisions
Jump to navigation
Jump to search
m (camelCase) |
m (more consistent layout and better tagging) |
||
Line 7: | Line 7: | ||
===Syntax terms=== | ===Syntax terms=== | ||
<table class="syntaxTable"> | <table class="syntaxTable"> | ||
<tr><th>% | <tr><th>%itemNum</th> | ||
<td>A numeric variable which will be set to the item number of the first item in the <var class="term">sl</var> <var>stringlist</var> that contains the search target string, or it is set to a 0 if no items match the search criterion.</td></tr> | <td>A numeric variable which will be set to the item number of the first item in the <var class="term">sl</var> <var>stringlist</var> that contains the search target string, or it is set to a 0 if no items match the search criterion.</td></tr> | ||
<tr><th>sl</th> | <tr><th>sl</th> | ||
Line 16: | Line 16: | ||
<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 last item in the <var>stringlist</var>.</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 last item in the <var>stringlist</var>.</td></tr> | ||
<tr><th>startCol</th> | <tr><th>startCol</th> | ||
<td>A number that specifies the starting column of the range of columns within which the | <td>A number that specifies the starting column of the range of columns within which the target <var class="term">string</var> is searched for. This is an optional argument, and it defaults to 1.</td></tr> | ||
<tr><th>endCol</th> | <tr><th>endCol</th> | ||
<td>A number that specifies the ending column of the range of columns within which the | <td>A number that specifies the ending column of the range of columns within which the target <var class="term">string</var> is searched for. This is an optional argument, and it defaults to 6124. If <var class="term">caseFlag</var> is a non-zero integer, the width of the searched column range is reduced to a maximum of 256.</td></tr> | ||
<tr><th>caseFlag</th> | <tr><th>caseFlag</th> | ||
<td>An indicator for case-insensitive comparisons. If this argument is a non-zero integer, the string comparisons use <var>stringlist</var> item data translated to uppercase (so the search string should be passed as an uppercase value). This is an optional argument, and it defaults to zero. If it is 1, the width of the searched column range is reduced to a maximum of 256.</td></tr> | <td>An indicator for case-insensitive comparisons. If this argument is a non-zero integer, the string comparisons use <var>stringlist</var> item data translated to uppercase (so the search target <var class="term">string</var> should be passed as an uppercase value). This is an optional argument, and it defaults to zero. If it is 1, the width of the searched column range is reduced to a maximum of 256.</td></tr> | ||
</table> | </table> | ||
Line 28: | Line 28: | ||
==Examples== | ==Examples== | ||
The following code locates a string anywhere in a a <var>stringlist</var> %list item, searching backwards starting at item 100.<pre> | <ol><li>The following code locates a string anywhere in a a <var>stringlist</var> <code>%list</code> item, searching backwards starting at item 100.<pre> | ||
%num = %list:locateUp('Vietnamerica', 100) | %num = %list:locateUp('Vietnamerica', 100) | ||
</pre> | </pre></ol> | ||
==See also== | ==See also== | ||
{{Template:Stringlist:LocateUp footer}} | {{Template:Stringlist:LocateUp footer}} |
Revision as of 02:50, 27 January 2011
Locate previous Stringlist item containing string (Stringlist class)
This method locates a specified string in a stringlist, searching the stringlist items in reverse order.
Syntax
%itemNum = sl:LocateUp( string, [[Start=] number], [[StartColumn=] number], - [[EndColumn=] number], [[CaseIndependent=] number], - [[ArbitraryQuote=] number])
Syntax terms
%itemNum | A numeric variable which will be set to the item number of the first item in the sl stringlist that contains the search target string, or it is set to a 0 if no items match the search criterion. |
---|---|
sl | A Stringlist object. |
string | The target string to be located. This is a required argument, and it must be no longer than 255 bytes. |
start | A number that indicates the item number at which the search is to begin. If this argument is not specified, searching begins at the last item in the stringlist. |
startCol | A number that specifies the starting column of the range of columns within which the target string is searched for. This is an optional argument, and it defaults to 1. |
endCol | A number that specifies the ending column of the range of columns within which the target string is searched for. This is an optional argument, and it defaults to 6124. If caseFlag is a non-zero integer, the width of the searched column range is reduced to a maximum of 256. |
caseFlag | An indicator for case-insensitive comparisons. If this argument is a non-zero integer, the string comparisons use stringlist item data translated to uppercase (so the search target string should be passed as an uppercase value). This is an optional argument, and it defaults to zero. If it is 1, the width of the searched column range is reduced to a maximum of 256. |
Usage notes
- LocateUp returns a 0 if the indicated string is not found, and it cancels the request for all other errors.
- While, under Sirius Mods Version 6.6 and later, stringlist items can be longer than 6124 bytes long, the LocateUp method will only look for matches in the first 6124 bytes of any Stringlist item.
Examples
- The following code locates a string anywhere in a a stringlist
%list
item, searching backwards starting at item 100.%num = %list:locateUp('Vietnamerica', 100)