UnicodeRight (Unicode function): Difference between revisions
Jump to navigation
Jump to search
m (1 revision) |
m (syntax terms and tags) |
||
Line 1: | Line 1: | ||
{{Template:Unicode:UnicodeRight subtitle}} | {{Template:Unicode:UnicodeRight subtitle}} | ||
<var>UnicodeRight</var> returns a specified number of the right-most characters of the method object string, possibly padding them on the left. | |||
of the method object string, possibly padding them on the left. | |||
==Syntax== | ==Syntax== | ||
{{Template:Unicode:UnicodeRight syntax}} | {{Template:Unicode:UnicodeRight syntax}} | ||
===Syntax terms=== | ===Syntax terms=== | ||
<table class="syntaxTable"> | <table class="syntaxTable"> | ||
<tr><th>% | <tr><th>%outUnicode</th> | ||
<td>A <var>Unicode</var> variable to receive the result of the <var>UnicodeRight</var> method. </td></tr> | <td>A <var>Unicode</var> variable to receive the result of the <var>UnicodeRight</var> method. </td></tr> | ||
<tr><th>unicode</th> | <tr><th>unicode</th> | ||
<td>A <var>Unicode</var> string. </td></tr> | <td>A <var>Unicode</var> string. </td></tr> | ||
<tr><th> | <tr><th>number</th> | ||
<td>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 | <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 class="term">pad</var> parameter. </td></tr> | ||
<tr><th> | <tr><th>pad</th> | ||
<td> | <td>Specifies the character used to pad the method object string on the left if it is shorter than the requested length. <var class="term">Pad</var> defaults to the null string (<code><nowiki>''</nowiki></code>), which means no padding is done. <var class="term">Pad</var> is a <var>[[Methods#Named parameters|Name-Required]]</var> parameter.</td></tr> | ||
</table> | </table> | ||
==Usage notes== | ==Usage notes== | ||
<ul> | <ul> | ||
<li>The | <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 class="term">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> is analogous to the <var>String</var> intrinsic <var>[[Right (String function)|Right]]</var> method. | ||
<li> | <li><var>UnicodeRight</var> function is available as of <var class="product">[[Sirius Mods|"Sirius Mods"]]</var> Version 7.5. | ||
most typically by using a blank as pad character. | |||
<li> | |||
the <var>String</var> intrinsic [[Right (String function)|Right]] method. | |||
</ul> | </ul> | ||
==Examples== | ==Examples== | ||
<ol><li> | |||
The following statement places the right-most 5 characters of %x into %y. | The following statement places the right-most 5 characters of %x into %y. If %x is shorter than 6 characters, then all of %x is copied into %y: | ||
If %x is shorter than 6 characters, then all of %x is copied into %y: | |||
<p class="code">%y = %x:unicodeRight(5) | <p class="code">%y = %x:unicodeRight(5) | ||
</p> | </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 Pad 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 <var>Unicode</var> string (which gets converted implicitly to <var>String</var>). | %pad is string len 4 | ||
<p class="code"> | %len is float | ||
%u2 unicode initial('inaugural') | [[PrintText statement|printText]] {%u2:unicodeRight(10, pad=' ')} | ||
%pad is string len 4 | printText {123:unicodeRight(10, pad='&#x40;':[[U (String function)|U]])} | ||
%len is float | end | ||
printText {%u2:unicodeRight(10, pad=' ')} | |||
printText {123:unicodeRight(10, pad='&#x40;':U)} | |||
</p> | </p> | ||
Line 53: | Line 45: | ||
<p class="output">inaugural | <p class="output">inaugural | ||
@@@@@@@123 | @@@@@@@123 | ||
</p> | </p></ol> | ||
==See also== | ==See also== | ||
{{Template:Unicode:UnicodeRight footer}} | {{Template:Unicode:UnicodeRight footer}} |
Revision as of 04:46, 25 February 2011
The right-most characters of the string (Unicode class)
UnicodeRight returns a 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 is analogous to the String intrinsic Right method.
- UnicodeRight function is available as of "Sirius Mods" Version 7.5.
Examples
-
The following statement places the right-most 5 characters of %x into %y. If %x is shorter than 6 characters, then all of %x is copied into %y:
%y = %x:unicodeRight(5)
- 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='@':U)} end
The result is:
inaugural @@@@@@@123