UnicodeLeft (Unicode function): Difference between revisions
Jump to navigation
Jump to search
m (1 revision) |
m (syntax terms, tags, links and printtext) |
||
Line 1: | Line 1: | ||
{{Template:Unicode:UnicodeLeft subtitle}} | {{Template:Unicode:UnicodeLeft subtitle}} | ||
<var>UnicodeLeft</var> returns the left-most characters of the method object string, possibly padding it on the right. | |||
possibly padding it on the right. | |||
==Syntax== | ==Syntax== | ||
{{Template:Unicode:UnicodeLeft syntax}} | {{Template:Unicode:UnicodeLeft 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>UnicodeLeft</var> method. </td></tr> | <td>A <var>Unicode</var> variable to receive the result of the <var>UnicodeLeft</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 left-most characters to return. If | <td>The number of the left-most characters to return. If <var class="term">unicode</var> 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 <var class="term">pad</var> parameter. </td></tr> | ||
<tr><th> | <tr><th>pad</th> | ||
<td> | <td>A single character used to pad <var class="term">unicode</var>, on the right, if it is shorter than the requested <var class="term">number</var>. <var class="term>pad</var> defaults to a null string (<code><nowiki>''</nowiki></code>) which means no padding is done. Pad is a name-required parameter.</td></tr> | ||
</table> | </table> | ||
==Usage notes== | ==Usage notes== | ||
<ul> | <ul><li>The <var class="term">length</var> value must be a non-negative number. A negative number results in request cancellation. | ||
<li>The | <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. | ||
A negative number results in request cancellation. | <li><var>UnicodeLeft</var> is identical to the <var>[[UnicodeSubstring (Unicode function)|UnicodeSubstring]])</var> with a 1 for the first argument. | ||
<li>The pad parameter value must be either null or a single character. | <li><var>UnicodeLeft</var> is analogous to the <var>[[Left (String function)|Left]]</var> <var>String</var> intrinsic method. | ||
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> | |||
<li> | |||
the <var>String</var> intrinsic | |||
</ul> | |||
==Examples== | ==Examples== | ||
<ol><li>The following statement displays <code>Model 2</code>: | |||
The following statement displays < | |||
<p class="code">%u is unicode initial('Model 204&#x2122;':U) | <p class="code">%u is unicode initial('Model 204&#x2122;':U) | ||
[[Intrinsic classes#printtext|printText]] {%u:unicodeLeft(7)} | [[Intrinsic classes#printtext|printText]] {%u:unicodeLeft(7)} | ||
</p> | </p> | ||
The following statement displays < | <li>The following statement displays <code>Model 204!!!</code>: | ||
<p class="code">%u is unicode initial('Model 204') | <p class="code">%u is unicode initial('Model 204') | ||
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>&#x2122;</code> (trademark) has no Ebcdic equivalent: | |||
The following statement gets a character translation exception | |||
because the <var>Unicode</var> character < | |||
Ebcdic equivalent: | |||
<p class="code">%u is unicode initial('Model 204&#x2122;':U) | <p class="code">%u is unicode initial('Model 204&#x2122;':U) | ||
printText {%u:unicodeLeft(10)} | printText {%u:unicodeLeft(10)} | ||
</p> | </p></ol> | ||
==See also== | ==See also== | ||
{{Template:Unicode:UnicodeLeft footer}} | {{Template:Unicode:UnicodeLeft footer}} |
Revision as of 07:37, 24 February 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 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.
- UnicodeLeft is identical to the UnicodeSubstring) with a 1 for the first argument.
- UnicodeLeft is analogous to the Left String intrinsic method.
- UnicodeLeft is available as of "Sirius Mods" Version 7.5.
Examples
- The following statement displays
Model 2
:%u is unicode initial('Model 204™':U) printText {%u:unicodeLeft(7)}
- The following statement displays
Model 204!!!
:%u is unicode initial('Model 204') printText {%u:unicodeLeft(12, pad='!')}
- The following statement gets a character translation exception because the Unicode character
™
(trademark) has no Ebcdic equivalent:%u is unicode initial('Model 204™':U) printText {%u:unicodeLeft(10)}