UnicodeRight (Unicode function): Difference between revisions

From m204wiki
Jump to navigation Jump to search
(Created page with "<span style="font-size:120%; color:black"><b>Right-most characters of string to specified length</b></span> UnicodeRight function [[Categor...")
 
mNo edit summary
 
(32 intermediate revisions by 6 users not shown)
Line 1: Line 1:
<span style="font-size:120%; color:black"><b>Right-most characters of string to specified length</b></span>
{{Template:Unicode:UnicodeRight subtitle}}
[[Category:Intrinsic Unicode methods|UnicodeRight function]]
<var>UnicodeRight</var> returns the specified number of the right-most characters of the method object string, possibly padding them on the left.
[[Category:Intrinsic methods]]
[[Category:System methods]]
<!--DPL?? Category:Intrinsic Unicode methods|UnicodeRight function: Right-most characters of string to specified length-->
<!--DPL?? Category:Intrinsic methods|UnicodeRight (Unicode function): Right-most characters of string to specified length-->
<!--DPL?? Category:System methods|UnicodeRight (Unicode function): Right-most characters of string to specified length-->


This function returns a specified number of the right-most characters
==Syntax==
of the method object string, possibly padding them on the left.
{{Template:Unicode:UnicodeRight syntax}}


The UnicodeRight function is available as of version 7.5  of the ''Sirius Mods''.
===Syntax terms===
===Syntax===
<table class="syntaxTable">
  %outUni = unicode:unicodeRight(length [,&nbsp;Pad=char])
<tr><th>%outUnicode</th>
====Syntax Terms====
<td>A <var>Unicode</var> variable to receive the result of the <var>UnicodeRight</var> method. </td></tr>
<dl>
<dt><i>%outUni</i>
<dd>A Unicode variable to receive the result of the UnicodeRight method.
<dt><i>unicode</i>
<dd>A Unicode string.
<dt><i>length</i>
<dd>The number of the right-most characters to return.
If the method object is shorter than the requested number of characters, it is either
padded to the requested length or the entire method object string is
returned with no padding, depending on the value of the Pad parameter.
<dt><b>Pad=</b><i>char</i>
<dd>The character used to pad the method object string on the left if
it is shorter than the requested length.
''char'' defaults to a null, which means no padding is done.
Pad is a name-required parameter.


</dl>
<tr><th>unicode</th>
===Usage Notes===
<td>A <var>Unicode</var> string. </td></tr>
 
<tr><th>number</th>
<td>The number of the right-most characters to return. If the method object, <var class="term">unicode</var>, is shorter than the requested number of characters, it is either padded to the requested length or the entire method object string is returned with no padding, depending on the value of the <var>Pad</var> parameter. </td></tr>
 
<tr><th><var>Pad</var></th>
<td>Specifies the character used to pad the method object string, on the left, if it is shorter than the requested length. <var>Pad</var> defaults to the null string (<tt><nowiki>''</nowiki></tt>), which means no padding is done. <var>Pad</var> is a [[Notation conventions for methods#Named parameters|name required]] parameter.</td></tr>
</table>
 
==Usage notes==
<ul>
<ul>
<li>The ''length'' value must be a non-negative number.
<li>The output length specified in <var class="term">number</var> value must be a non-negative number. A negative number results in request cancellation.
A negative number results in request cancellation.
<li>The <var>Pad</var> parameter value must be either null or a single character. A longer value results in a compilation error.
<li>The pad parameter value must be either null or a single character.
<li><var>UnicodeRight</var> can be useful for right-justifying a value in a string, most typically by using a blank as pad character.
A longer value results in a compilation error.
<li><var>UnicodeRight</var> function is available as of <var class="product">Sirius Mods</var> Version 7.5.
<li>The Right method can be useful for right-justifying a value in a string,
most typically by using a blank as pad character.
<li>The UnicodeRight method is analogous to
the String intrinsic Right method (??[[Right (String function)|Right]]).
</ul>
</ul>
===Examples===


The following statement places the right-most 5 characters of %x into %y.
==Examples==
If %x is shorter than 6 characters, then all of %x is copied into %y:
<ol>
<pre>
<li>The following statement places the right-most 5 characters of <code>%x</code> into <code>%y</code>. If <code>%x</code> is shorter than 6 characters, all of <code>%x</code> is copied into <code>%y</code>:
    %y = %x:unicodeRight(5)
<p class="code">%y = %x:unicodeRight(5)
</pre>
</p>


The following request right-aligns a text string and a number, padding each
<li>The following request right-aligns a text string and a number, padding each on the left with a different character. This example also shows that the argument for the method's <var>Pad</var> parameter may be a <var>Unicode</var> string (which gets converted implicitly to <var>String</var>).
on the left with a different character.
<p class="code">begin
This example also shows that the argument for the method's Pad parameter
  %u2 unicode initial('inaugural')
may be a Unicode string (which gets converted implicitly to String).
  %pad is string len 4
<pre>
  %len is float
    Begin
  [[PrintText statement|printText]] {%u2:unicodeRight(10, pad=' ')}
    %u2 unicode initial('inaugural')
  printText {123:unicodeRight(10, pad='&amp;#x40;':[[U (String function)|U]])}
    %pad is string len 4
end
    %len is float
</p>
    printText {%u2:unicodeRight(10, pad=' ')}
The result is:
    printText {123:unicodeRight(10, pad='&amp;#x40;':U)}
<p class="output">inaugural
    End
@@@@@@@123
</pre>
</p></ol>


The result is:
==See also==
<pre>
<ul>
    inaugural
<li><var>UnicodeRight</var> is analogous to the <var>String</var> intrinsic <var>[[Right (String function)|Right]]</var> method.
    @@@@@@@123
</ul>
</pre>


The U constant function used in the example is described ??[[U (String function)|U]].
{{Template:Unicode:UnicodeRight footer}}
For information about the PrintText statement, see the list
item [[??]] refid=intprnt..

Latest revision as of 17:40, 6 November 2012

The right-most characters of the string (Unicode class)

UnicodeRight returns the specified number of the right-most characters of the method object string, possibly padding them on the left.

Syntax

%outUnicode = unicode:UnicodeRight( number, [Pad= c])

Syntax terms

%outUnicode A Unicode variable to receive the result of the UnicodeRight method.
unicode A Unicode string.
number The number of the right-most characters to return. If the method object, unicode, is shorter than the requested number of characters, it is either padded to the requested length or the entire method object string is returned with no padding, depending on the value of the Pad parameter.
Pad Specifies the character used to pad the method object string, on the left, if it is shorter than the requested length. Pad defaults to the null string (''), which means no padding is done. Pad is a name required parameter.

Usage notes

  • The output length specified in number value must be a non-negative number. A negative number results in request cancellation.
  • The Pad parameter value must be either null or a single character. A longer value results in a compilation error.
  • UnicodeRight can be useful for right-justifying a value in a string, most typically by using a blank as pad character.
  • UnicodeRight function is available as of Sirius Mods Version 7.5.

Examples

  1. The following statement places the right-most 5 characters of %x into %y. If %x is shorter than 6 characters, all of %x is copied into %y:

    %y = %x:unicodeRight(5)

  2. The following request right-aligns a text string and a number, padding each on the left with a different character. This example also shows that the argument for the method's Pad parameter may be a Unicode string (which gets converted implicitly to String).

    begin %u2 unicode initial('inaugural') %pad is string len 4 %len is float printText {%u2:unicodeRight(10, pad=' ')} printText {123:unicodeRight(10, pad='&#x40;':U)} end

    The result is:

    inaugural @@@@@@@123

See also

  • UnicodeRight is analogous to the String intrinsic Right method.