$Lstr Substr: Difference between revisions

From m204wiki
Jump to navigation Jump to search
m (1 revision)
(Automatically generated page update)
 
(22 intermediate revisions by 3 users not shown)
Line 2: Line 2:
<span class="pageSubtitle">Substring of a longstring</span>
<span class="pageSubtitle">Substring of a longstring</span>


<p class="warning">Most Sirius $functions have been deprecated in favor of Object Oriented methods. The OO equivalent for the $Lstr_Substr function is the [[Substring (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_Substr function is <var>[[Substring (String function)|Substring]]</var>.</p>


This function takes a string or longstring input and produces a substring of the input, possibly padded to an indicated length.  
This function takes a string or longstring input and produces a substring of the input, possibly padded to an indicated length.  
Line 17: Line 17:


==Syntax==
==Syntax==
<p class="syntax"><section begin="syntax" />%result = $Lstr_Substr(longstring, start, len, pad)
<p class="syntax"><span class="term">%result</span> = $Lstr_Substr(longstring, start, len, pad)
<section end="syntax" /></p>
<p class="caption">$Lstr_Substr function
</p>
</p>
<p class="caption">%result is a substring of the input longstring, padded with the pad character if necessary.</p>


<var>$Lstr_Substr</var> acts very much like $SUBSTR except
<p><var class="term">%result</var> is a substring of the input longstring, padded with the pad character if necessary.</p>
 
==Usage notes==
<ul>
<li><var>$Lstr_Substr</var> acts very much like $SUBSTR except:


<ul>
<ul>
Line 32: Line 33:
<li>It can operate on LONGSTRING inputs.  
<li>It can operate on LONGSTRING inputs.  
<li>It produces a LONGSTRING output.
<li>It produces a LONGSTRING output.
</ul>
</ul>
</ul>


For example
==Examples==
 
<ol>
<p class="code"> %BIG = $Lstr_Substr('Gryffindor', 5, 4)
<li>To set %BIG to <code>find</code>:
<p class="code">%BIG = $Lstr_Substr('Gryffindor', 5, 4)
</p>
</p>


sets %BIG to "find" and
<li>To set %BIG to <code>in</code> followed by 298 asterisks:


<p class="code"> %BIG = $Lstr_Substr('Slytherin', 8, 300, '*')
<p class="code">%BIG = $Lstr_Substr('Slytherin', 8, 300, '*')
</p>
</p>
</ol>


sets %BIG to "in" followed by 298 asterisks.
==Products authorizing {{PAGENAMEE}}==
 
<ul class="smallAndTightList">
<var>$Lstr_Substr</var> is only available in <var class="product">[[Sirius Mods]]</var> Version 6.2 and later.<p>
<li>[[List of $functions|Sirius functions]]</li>
 
<h2>Products authorizing {{PAGENAMEE}}</h2><ul class="smallAndTightList">
<li>[[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_Substr
</p>
[[Category:$Functions|$Lstr_Substr]]
[[Category:$Functions|$Lstr_Substr]]

Latest revision as of 22:52, 20 September 2018

Substring of a longstring

Note: Many $functions have been deprecated in favor of Object Oriented methods. The OO equivalent for the $Lstr_Substr function is Substring.

This function takes a string or longstring input and produces a substring of the input, possibly padded to an indicated length.

The $Lstr_Substr function accepts four arguments and returns a string result.

The first argument is an arbitrary string or longstring. This is a required argument.

The second argument is a number between 1 and 2**31-1 that indicates the starting character in the input string. This is a required argument.

The third argument is a number between 1 and 2**31-1 that indicates the length of the result string. This is an optional argument and defaults to the number of characters in the input string starting at the position indicated by the second argument.

The fourth argument is a string containing a single character to be used as the pad character if the result length is longer than the string specified by argument one. This is an optional argument and defaults to a blank.

Syntax

%result = $Lstr_Substr(longstring, start, len, pad)

%result is a substring of the input longstring, padded with the pad character if necessary.

Usage notes

  • $Lstr_Substr acts very much like $SUBSTR except:
    • It pads the result to the length indicated by the third argument if the third argument is specified.
    • It has a fourth pad character argument.
    • It cancels the request if the result target is too short to hold the result.
    • It cancels the request if the pad character argument is longer than one byte.
    • It can operate on LONGSTRING inputs.
    • It produces a LONGSTRING output.

Examples

  1. To set %BIG to find:

    %BIG = $Lstr_Substr('Gryffindor', 5, 4)

  2. To set %BIG to in followed by 298 asterisks:

    %BIG = $Lstr_Substr('Slytherin', 8, 300, '*')

Products authorizing $Lstr_Substr