UnicodeRight (Unicode function): Difference between revisions
Jump to navigation
Jump to search
m (what was I thinking with those blank lines) |
m (what was I thinking with those blank lines) |
||
Line 12: | Line 12: | ||
<tr><th>number</th> | <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> | <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>Pad</th> | <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 (<code><nowiki>''</nowiki></code>), which means no padding is done. <var>Pad</var> is a <var>[[Methods#Named parameters|NameRequired]]</var> parameter.</td></tr> | <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 (<code><nowiki>''</nowiki></code>), which means no padding is done. <var>Pad</var> is a <var>[[Methods#Named parameters|NameRequired]]</var> parameter.</td></tr> | ||
</table> | </table> | ||
Line 35: | Line 35: | ||
%len is float | %len is float | ||
[[PrintText statement|printText]] {%u2:unicodeRight(10, pad=' ')} | [[PrintText statement|printText]] {%u2:unicodeRight(10, pad=' ')} | ||
printText {123:unicodeRight(10, pad='&#x40;':[[U (String function)|U]])} | printText {123:unicodeRight(10, pad='&amp;#x40;':[[U (String function)|U]])} | ||
end | end | ||
</p> | </p> |
Revision as of 00:55, 13 April 2011
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 NameRequired 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
-
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='&#x40;':U)} end
The result is:
inaugural @@@@@@@123
See also
- UnicodeRight is analogous to the String intrinsic Right method.