$Lstr Substr: Difference between revisions

From m204wiki
Jump to navigation Jump to search
m (1 revision)
mNo edit summary
Line 2: Line 2:
<span class="pageSubtitle"><section begin="desc" />Substring of a longstring<section end="desc" /></span>
<span class="pageSubtitle"><section begin="desc" />Substring of 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_Substr function is [[to be entered]].</p>
<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>


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 15: Line 15:


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.
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==
==Syntax==
<p class="syntax"><section begin="syntax" /> %RESULT = $Lstr_Substr(longstring, start, len, pad)
<p class="syntax"><section begin="syntax" /> %RESULT = $Lstr_Substr(longstring, start, len, pad)
Line 23: Line 24:


$Lstr_Substr acts very much like $SUBSTR except
$Lstr_Substr acts very much like $SUBSTR except
<ul>
<ul>
<li>It pads the result to the length indicated by the third argument if the third argument is specified.  
<li>It pads the result to the length indicated by the third argument if the third argument is specified.  
<li>It has a fourth pad character argument.  
<li>It has a fourth pad character argument.  
Line 34: Line 35:


For example
For example
<p class="code"> %BIG = $Lstr_Substr('Gryffindor', 5, 4)
<p class="code"> %BIG = $Lstr_Substr('Gryffindor', 5, 4)
</p>
</p>
sets %BIG to "find.&CQ. and
sets %BIG to "find.&CQ. and
<p class="code"> %BIG = $Lstr_Substr('Slytherin', 8, 300, '*')
<p class="code"> %BIG = $Lstr_Substr('Slytherin', 8, 300, '*')
</p>
</p>
sets %BIG to "in&CQ. followed by 298 asterisks.


For more information see :hdref refid=lstr..  
sets %BIG to "in" followed by 298 asterisks.  


$Lstr_Substr is only available in ''[[Sirius Mods]]'' Version 6.2 and later.<p>
$Lstr_Substr is only available in ''[[Sirius Mods]]'' Version 6.2 and later.<p>

Revision as of 14:11, 11 February 2011

<section begin="desc" />Substring of a longstring<section end="desc" />

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).

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

<section begin="syntax" /> %RESULT = $Lstr_Substr(longstring, start, len, pad) <section end="syntax" />

$Lstr_Substr function

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

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

For example

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

sets %BIG to "find.&CQ. and

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

sets %BIG to "in" followed by 298 asterisks.

$Lstr_Substr is only available in Sirius Mods Version 6.2 and later.

Products authorizing $Lstr_Substr