$Lstr_Right

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.

Rightmost characters of a longstring

Note: Many $functions have been deprecated in favor of Object Oriented methods. The OO equivalent for the $Lstr_Right function is the Right function.

This function takes a string or longstring input and produces the rightmost characters of the input, possibly padded to an indicated length.

The $Lstr_Right function accepts three arguments and returns a string result.

The first argument is an arbitrary string or longstring. This is a required argument.

The second argument is a number between 1 and 2**31-1 that indicates the result length. This is a required argument.

The third argument is a string containing a single character to be used as the pad character if the result length is longer than the string specified by argument one. This is an optional argument and defaults to a blank.

Syntax

%result = $Lstr_Right(longstring, len, pad)

%result is the rightmost characters of the input longstring, padded with the pad character if necessary.

Usage notes

  • $Lstr_Right acts very much like $PAD except:
    • The target length and pad character arguments are reversed.
    • It cancels the request if the result target is too short to hold the result.
    • It cancels the request if the pad character argument is longer than one byte.
    • It can operate on LONGSTRING inputs.
    • It produces a LONGSTRING output.

Examples

  1. To set %BIG to all:

    %BIG = $Lstr_Right('McGonagall', 3)

  2. To set %BIG to 290 question marks followed by Dumbledore:

    %BIG = $Lstr_Right('Dumbledore', 300, '?')

Products authorizing $Lstr_Right