Left (String function)

From m204wiki
Revision as of 18:08, 11 July 2017 by JAL (talk | contribs) (misc formatting)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

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

The Left intrinsic function returns the left-most characters of the method object string, possibly padding it on the right.


%outString = string:Left( length, [Pad= c])

Syntax terms

%outString A variable to receive the string result of the Left method.
string The input, method object string to which the method is applied.
length The number of the left-most bytes to return. If the method object is shorter than the requested number of bytes, 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 This optional, name required, parameter is the character used to pad the method object string on the right if it is shorter than the requested length. c defaults to a blank. If set to null, no padding is applied.

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.
  • Left is identical to the Substring method with 1 as its first argument.


  1. The following statement places the left-most 5 bytes of %x into %y. If %x contains fewer than 6 bytes, then all of %x is copied into %y, padded on the right with blanks:

    %y = %x:left(5)

  2. The following statement displays Wheeeee:

    printText {'Wh':left(7, pad='e')}

See also