UnicodeRight (Unicode function): Difference between revisions

From m204wiki
Jump to navigation Jump to search
m (1 revision)
m (1 revision)
Line 2: Line 2:
[[Category:Unicode methods|UnicodeRight function]]
[[Category:Unicode methods|UnicodeRight function]]
[[Category:Intrinsic methods]]
[[Category:Intrinsic methods]]
<!--DPL?? Category:Unicode methods|<var>UnicodeRight</var> function: Right-most characters of string to specified length-->
<!--DPL?? Category:<var>Unicode</var> methods|<var>UnicodeRight</var> function: Right-most characters of string to specified length-->
<!--DPL?? Category:Intrinsic methods|<var>UnicodeRight</var> (Unicode function): Right-most characters of string to specified length-->
<!--DPL?? Category:Intrinsic methods|<var>UnicodeRight</var> (<var>Unicode</var> function): Right-most characters of string to specified length-->
<!--DPL?? Category:System methods|<var>UnicodeRight</var> (Unicode function): Right-most characters of string to specified length-->
<!--DPL?? Category:<var>System</var> methods|<var>UnicodeRight</var> (<var>Unicode</var> function): Right-most characters of string to specified length-->


This function returns a specified number of the right-most characters
This function returns a specified number of the right-most characters
Line 15: Line 15:
<table class="syntaxTable">
<table class="syntaxTable">
<tr><th><i>%outUni</i></th>
<tr><th><i>%outUni</i></th>
<td>A Unicode 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><i>unicode</i></th>
<tr><th><i>unicode</i></th>
<td>A Unicode string. </td></tr>
<td>A <var>Unicode</var> string. </td></tr>
<tr><th><i>length</i></th>
<tr><th><i>length</i></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 Pad parameter. </td></tr>
<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 Pad parameter. </td></tr>
Line 32: Line 32:
most typically by using a blank as pad character.
most typically by using a blank as pad character.
<li>The <var>UnicodeRight</var> method is analogous to
<li>The <var>UnicodeRight</var> method is analogous to
the String intrinsic [[Right (String function)|Right]] method.
the <var>String</var> intrinsic [[Right (String function)|Right]] method.
</ul>
</ul>


Line 46: Line 46:
on the left with a different character.
on the left with a different character.
This example also shows that the argument for the method's Pad parameter
This example also shows that the argument for the method's Pad parameter
may be a Unicode string (which gets converted implicitly to String).
may be a <var>Unicode</var> string (which gets converted implicitly to <var>String</var>).
<pre>
<pre>
     Begin
     Begin

Revision as of 15:49, 20 January 2011

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

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

The UnicodeRight function is available as of version 7.5 of the Sirius Mods.

Syntax

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

Syntax terms

%outUni A Unicode variable to receive the result of the UnicodeRight method.
unicode A Unicode string.
length 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.
Pad=char 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.

Usage notes

  • The length 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.
  • The Right method can be useful for right-justifying a value in a string, most typically by using a blank as pad character.
  • The UnicodeRight method is analogous to the String intrinsic Right method.

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

The U constant function used in the example is described ??U. For information about the PrintText statement, see the list item ?? refid=intprnt..