UnicodeLeft (Unicode function): Difference between revisions
Jump to navigation
Jump to search
m (→Usage notes) |
m (misc formatting) |
||
(One intermediate revision by one other user not shown) | |||
Line 17: | Line 17: | ||
<tr><th><var>Pad</var></th> | <tr><th><var>Pad</var></th> | ||
<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">c</var> defaults to a null string (<tt><nowiki>''</nowiki></tt>) which means no padding is done. <var>Pad</var> is a [[Notation conventions for methods#Named parameters|name required]] parameter.</td></tr> | <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">c</var> defaults to a null string (<tt><nowiki>''</nowiki></tt>) which means no padding is done. | ||
<p> | |||
<var>Pad</var> is a [[Notation conventions for methods#Named parameters|name required]] parameter, and <var>Pad</var> is a <var>Unicode</var> string. Like all <var>Unicode</var> arguments, if an EBCDIC string is specified, it is, converted to <var>Unicode</var>. </p></td></tr> | |||
</table> | </table> | ||
==Usage notes== | ==Usage notes== | ||
<ul> | <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">number</var> value must be a non-negative number. A negative number results in request cancellation. </li> | ||
<li>The <var>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 | <li>The <var>Pad</var> parameter value must be either null or a single character. A longer value results in a compilation error. </li> | ||
<li><var>UnicodeLeft</var> is identical to <var>[[UnicodeSubstring (Unicode function)|UnicodeSubstring]]</var> with <code>1</code> as its first argument. </li> | |||
<li><var>UnicodeLeft</var> is analogous to the <var>[[Left (String function)|Left]]</var> <var>String</var> intrinsic method. </li> | |||
</ul> | </ul> | ||
Line 45: | Line 51: | ||
==See also== | ==See also== | ||
{{Template:Unicode:UnicodeLeft footer}} | {{Template:Unicode:UnicodeLeft footer}} |
Latest revision as of 18:31, 11 July 2017
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. c defaults to a null string ('') which means no padding is done.
Pad is a name required parameter, and Pad is a Unicode string. Like all Unicode arguments, if an EBCDIC string is specified, it is, converted to Unicode. |
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 identical to UnicodeSubstring with
1
as its first argument. - UnicodeLeft is analogous to the Left String intrinsic method.
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)}