UnicodeLeft (Unicode function): Difference between revisions

From m204wiki
Jump to navigation Jump to search
m (1 revision)
m (1 revision)
Line 19: Line 19:
<ul><li>The <var class="term">number</var> value must be a non-negative number.  A negative number results in request cancellation.
<ul><li>The <var class="term">number</var> value must be a non-negative number.  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 <var class="term">pad</var> parameter value must be either null or a single character.  A longer value results in a compilation error.
<li><var>UnicodeLeft</var> is available as of <var class="product">[[Sirius Mods|"Sirius Mods"]]</var> Version 7.5.</ul>
<li><var>UnicodeLeft</var> is available as of <var class="product">[[Sirius Mods|Sirius Mods]]</var> Version 7.5.</ul>


==Examples==
==Examples==
<ol><li>The following statement displays <code>Model 2</code>:
<ol><li>The following statement displays <code>Model 2</code>:
<p class="code">%u is unicode initial('Model 204&amp;amp;#x2122;':[[U (String function)|U]])
<p class="code">%u is unicode initial('Model 204&amp;amp;amp;#x2122;':[[U (String function)|U]])
[[Intrinsic classes#printtext|printText]] {%u:unicodeLeft(7)}
[[Intrinsic classes#printtext|printText]] {%u:unicodeLeft(7)}
</p>
</p>
Line 30: Line 30:
printText {%u:unicodeLeft(12, pad='!')}
printText {%u:unicodeLeft(12, pad='!')}
</p>
</p>
<li>The following statement gets a character translation exception because the <var>Unicode</var> character <code>&amp;amp;#x2122;</code> (trademark) has no Ebcdic equivalent:
<li>The following statement gets a character translation exception because the <var>Unicode</var> character <code>&amp;amp;amp;#x2122;</code> (trademark) has no Ebcdic equivalent:
<p class="code">%u is unicode initial('Model 204&amp;amp;#x2122;':U)
<p class="code">%u is unicode initial('Model 204&amp;amp;amp;#x2122;':U)
printText {%u:unicodeLeft(10)}
printText {%u:unicodeLeft(10)}
</p></ol>
</p></ol>

Revision as of 17:46, 4 May 2011

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

UnicodeLeft returns the left-most characters of the method object string, possibly padding it on the right.

Syntax

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

Syntax terms

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

Usage notes

  • The 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.
  • UnicodeLeft is available as of Sirius Mods Version 7.5.

Examples

  1. The following statement displays Model 2:

    %u is unicode initial('Model 204&amp;amp;#x2122;':U) printText {%u:unicodeLeft(7)}

  2. The following statement displays Model 204!!!:

    %u is unicode initial('Model 204') printText {%u:unicodeLeft(12, pad='!')}

  3. The following statement gets a character translation exception because the Unicode character &amp;amp;#x2122; (trademark) has no Ebcdic equivalent:

    %u is unicode initial('Model 204&amp;amp;#x2122;':U) printText {%u:unicodeLeft(10)}

See also

  • UnicodeLeft is identical to the UnicodeSubstring with a 1 for the first argument.
  • UnicodeLeft is analogous to the Left String intrinsic method.