Right (String function): Difference between revisions

From m204wiki
Jump to navigation Jump to search
m (1 revision)
m (1 revision)
Line 38: Line 38:
[[List of intrinsic String methods]]
[[List of intrinsic String methods]]


[[Category:Intrinsic String methods|Right function]]
[[Category:String methods|Right function]]
[[Category:Intrinsic methods]]
[[Category:Intrinsic methods]]

Revision as of 14:21, 19 January 2011

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


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

Right is available as of version 7.2 of the Sirius Mods.

Syntax

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

Syntax terms

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

Usage notes

  • The length must be a non-negative number. A negative number results in request cancellation.
  • The pad parameter must be either null 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 7.3 and higher.
  • The Right method can be useful for right-justifying a value in a string, most typically by using a blank as pad character.

Examples

The following places the right-most 5 bytes of %x into %y. If %x is shorter than 6 bytes, then all of %x is copied into %y:

   %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

List of intrinsic String methods