Right (String function)

From m204wiki
Revision as of 01:42, 24 February 2012 by JAL2 (talk | contribs)
Jump to navigation Jump to search

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


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

Syntax

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

Syntax terms

%outString A variable to receive the string result of the Right method.
string The input, method object, string to which the method is applied.
length The number of the right-most bytes to return. If the method object string is shorter than the requested length, 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 used to pad the method object, string, on the left, if it is shorter than the requested length. Pad defaults to a single blank space. If set to the null string, no padding is performed.

Usage notes

  • The length value must be a non-negative number. A negative number results in request cancellation.
  • The Pad argument must be either the null string or a single character. A longer value results in request cancellation in Sirius Mods Version 7.2 and in a compilation error in Sirius Mods Version 7.3 and higher.
  • Right can be useful for right-justifying a value in a string, most typically by using a blank space as pad character.
  • Right is available as of Sirius Mods version 7.2.

Examples

The following places the right-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 left with blanks:

%y = %x:right(5)

The following request right-justifies the numbers 7, 123, and 99, and it left-justifies the number 88:

begin printText {7:right(5)} printText {123:right(5)} printText {99:right(5)} printText {88:right(5, pad='')} end

See also