UnicodeLeft (Unicode function)

From m204wiki
Jump to navigation Jump to search
The printable version is no longer supported and may have rendering errors. Please update your browser bookmarks and please use the default browser print function instead.

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

  1. The following statement displays Model 2:

    %u is unicode initial('Model 204™':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 ™ (trademark) has no EBCDIC equivalent:

    %u is unicode initial('Model 204™':U) printText {%u:unicodeLeft(10)}

See also