$Lstr Index: Difference between revisions

From m204wiki
Jump to navigation Jump to search
m (1 revision)
(Automatically generated page update)
 
(35 intermediate revisions by 3 users not shown)
Line 2: Line 2:
<span class="pageSubtitle">Find a string inside a longstring</span>
<span class="pageSubtitle">Find a string inside a longstring</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 are the [[PositionOf (String function)]] and the [[PositionIn (String function)]].</p>
<p class="warn"><b>Note: </b>Many $functions have been deprecated in favor of Object Oriented methods. The OO equivalent for the $Lstr_Index function are <var>[[PositionOf (String function)|PositionOf]]</var> and <var>[[PositionIn (String function)|PositionIn]]</var>.</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.  


The $Lstr_Index function accepts three arguments and returns a numeric result.  
The <var>$Lstr_Index</var> function accepts three arguments and returns a numeric result.  


The first argument is an arbitrary longstring. This is a required argument.  
The first argument is an arbitrary longstring. This is a required argument.  
Line 15: Line 15:


==Syntax==
==Syntax==
<p class="syntax"><section begin="syntax" /> %RESULT = $Lstr_Index(longstring, str, start)
<p class="syntax"><span class="term">%result</span> = $Lstr_Index(longstring, str, start)
<section end="syntax" /></p>
<p class="caption">$Lstr_Index function
</p>
</p>
<p class="caption">%RESULT is the position in longstring of :hp1.str:ehp1., if there's a match after start, or is 0 if not.</p>


<var>$Lstr_Index</var> acts very much like $INDEX except
<p><var class="term">%result</var> is the position in longstring of <var class="term">str</var>, if there is a match after <var class="term">start</var>, or it is 0 if not.</p>


==Usage notes==
<ul>
<li><var>$Lstr_Index</var> 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.  
<li>It can operate on LONGSTRING inputs.
<li>It can operate on LONGSTRING inputs.
</ul>
</ul>
</ul>


For example
==Examples==
 
<ol>
<p class="code"> %X = $Lstr_Index('Beauxbatons', 'bat')
<li>To set %X to 6:
<p class="code">%X = $Lstr_Index('Beauxbatons', 'bat')
</p>
</p>


sets %X to 6 and
<li>To set %X to 13:
 
<p class="code"> %X = $Lstr_Index('Dudley Dursley', 'ey', 8)
<p class="code"> %X = $Lstr_Index('Dudley Dursley', 'ey', 8)
</p>
</p>
</ol>


sets %X to 13.
==Products authorizing {{PAGENAMEE}}==
 
<var>$Lstr_Index</var> is only available in <var class="product">[[Sirius Mods]]</var> Version 6.2 and later.<p>
 
<ul class="smallAndTightList">
<ul class="smallAndTightList">
<li>[[Sirius functions]]</li>
<li>[[List of $functions|Sirius functions]]</li>
<li>[[Fast/Unload User Language Interface]]</li>
<li>[[Fast/Unload User Language Interface]]</li>
<li>[[Janus Open Client]]</li>
<li>[[Media:JoclrNew.pdf|Janus Open Client]]</li>
<li>[[Janus Open Server]]</li>
<li>[[Media:JosrvrNew.pdf|Janus Open Server]]</li>
<li>[[Janus Sockets]]</li>
<li>[[Janus Sockets]]</li>
<li>[[Janus Web Server]]</li>
<li>[[Janus Web Server]]</li>
<li>[[Japanese functions]]</li>
<li>Japanese functions</li>
<li>[[Sir2000 Field Migration Facility]]</li>
<li>[[Media:SirfieldNew.pdf|Sir2000 Field Migration Facility]]</li>


</ul>
</ul>
   
   
</p>
<p class="caption">Products authorizing $Lstr_Index
</p>
[[Category:$Functions|$Lstr_Index]]
[[Category:$Functions|$Lstr_Index]]

Latest revision as of 22:52, 20 September 2018

Find a string inside a longstring

Note: Many $functions have been deprecated in favor of Object Oriented methods. The OO equivalent for the $Lstr_Index function are PositionOf and PositionIn.

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

%result = $Lstr_Index(longstring, str, start)

%result is the position in longstring of str, if there is a match after start, or it is 0 if not.

Usage notes

  • $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.

Examples

  1. To set %X to 6:

    %X = $Lstr_Index('Beauxbatons', 'bat')

  2. To set %X to 13:

    %X = $Lstr_Index('Dudley Dursley', 'ey', 8)

Products authorizing $Lstr_Index