$Lstr Index: Difference between revisions
m (1 revision) |
mNo edit summary |
||
Line 2: | Line 2: | ||
<span class="pageSubtitle"><section begin="desc" />Find a string inside a longstring<section end="desc" /></span> | <span class="pageSubtitle"><section begin="desc" />Find a string inside a longstring<section end="desc" /></span> | ||
<p class="warning">Most Sirius $functions have been deprecated in favor of Object Oriented methods. The OO equivalent for the $Lstr_Index function is [[ | <p class="warning">Most Sirius $functions have been deprecated in favor of Object Oriented methods. The OO equivalent for the $Lstr_Index function is are the [[PositionOf (String function)]] and the [[PositionIn (String function)]].</p> | ||
This function takes two longstring inputs and produces the position of one input inside the other. | This function takes two longstring inputs and produces the position of one input inside the other. | ||
Line 13: | Line 13: | ||
The third argument is a number indicating the position within the first string that a search for a match is to being. This is an optional argument and defaults to 1 meaning the first character. | The third argument is a number indicating the position within the first string that a search for a match is to being. This is an optional argument and defaults to 1 meaning the first character. | ||
==Syntax== | ==Syntax== | ||
<p class="syntax"><section begin="syntax" /> %RESULT = $Lstr_Index(longstring, str, start) | <p class="syntax"><section begin="syntax" /> %RESULT = $Lstr_Index(longstring, str, start) | ||
Line 21: | Line 22: | ||
$Lstr_Index acts very much like $INDEX except | $Lstr_Index acts very much like $INDEX except | ||
<ul> | <ul> | ||
<li>It allows a start position other than 1 (argument 3). | <li>It allows a start position other than 1 (argument 3). | ||
<li>It cancels the request if the string being searched for (argument 2) is longer than 255 bytes. | <li>It cancels the request if the string being searched for (argument 2) is longer than 255 bytes. | ||
Line 29: | Line 30: | ||
For example | For example | ||
<p class="code"> %X = $Lstr_Index('Beauxbatons', 'bat') | <p class="code"> %X = $Lstr_Index('Beauxbatons', 'bat') | ||
</p> | </p> | ||
sets %X to 6 and | sets %X to 6 and | ||
<p class="code"> %X = $Lstr_Index('Dudley Dursley', 'ey', 8) | <p class="code"> %X = $Lstr_Index('Dudley Dursley', 'ey', 8) | ||
</p> | </p> | ||
sets %X to 13. | sets %X to 13. | ||
$Lstr_Index is only available in ''[[Sirius Mods]]'' Version 6.2 and later.<p> | $Lstr_Index is only available in ''[[Sirius Mods]]'' Version 6.2 and later.<p> |
Revision as of 21:39, 10 February 2011
<section begin="desc" />Find a string inside a longstring<section end="desc" />
Most Sirius $functions have been deprecated in favor of Object Oriented methods. The OO equivalent for the $Lstr_Index function is are the PositionOf (String function) and the PositionIn (String function).
This function takes two longstring inputs and produces the position of one input inside the other.
The $Lstr_Index function accepts three arguments and returns a numeric result.
The first argument is an arbitrary longstring. This is a required argument.
The second argument is a longstring whose length, ironically, must be 255 bytes or less. This is a required argument.
The third argument is a number indicating the position within the first string that a search for a match is to being. This is an optional argument and defaults to 1 meaning the first character.
Syntax
<section begin="syntax" /> %RESULT = $Lstr_Index(longstring, str, start) <section end="syntax" />
$Lstr_Index acts very much like $INDEX except
- It allows a start position other than 1 (argument 3).
- It cancels the request if the string being searched for (argument 2) is longer than 255 bytes.
- It can operate on LONGSTRING inputs.
For example
%X = $Lstr_Index('Beauxbatons', 'bat')
sets %X to 6 and
%X = $Lstr_Index('Dudley Dursley', 'ey', 8)
sets %X to 13.
$Lstr_Index is only available in Sirius Mods Version 6.2 and later.