RIGHTCOPY
Syntax
![]()
Command
Mandatory parameter Optional parameter Mandatory keyword Optional keyword |
RIGHTCOPY (<Value>, <N-chars>[, <Ignore trailing spaces>])
Description
Returns the last <N-chars> of <Value>. When <N-chars> is greater than the length of <Value> only the available characters are returned.
Diagram
Returned value type
Realstring
Parameters
Parameter | Description |
<Value> | The value to copy from. Must be of type Alpha, String, Realstring, Numeric or Financial. |
<N-chars> | The number of characters to copy from the right. Must be of type Numeric, integer or a literal value. |
<Ignore trailing spaces> | Whether to ignore trailing spaces in an Alpha or Realstring or a formatted Numeric/Financial. |
Remarks
When at runtime <N-chars> has a value less or equal than zero, an empty string will be returned.
When <Value> is of type Numeric or Financial will always be copied from the end with no trailing spaces, unless full zero suppress or a format allowing trailing spaces has been set. In that case the <Ignore trailing spaces> can be used. When a format is defined for the Numeric or Financial the format will be used for the copy, otherwise normal formatting rules for copying to an alpha field will be used.
Examples
var
Sa-5 : Alpha 5
Fin-5 : Financial 5
Sn-82 : Numeric 8.2 Format '999,999.99'
Rlstr : Realstring
Result : Realstring
code
Sa-5 := 'abcd'
Fin-5 := -3
Sn-82 := 123456.78
Rlstr := 'Demo RightCopy '
Result := Rightcopy (Sa-5, 2) // 'd '
Result := Rightcopy (Sa-5, 2, true) // 'cd'
Result := Rightcopy (Sa-5, 5, true) // 'abcd', copies only the 4 avaialble characters
Result := Rightcopy (Sa-5, -2) // Rejected by compiler
Result := Rightcopy (Sn-82, 4) // 6.78
Result := Rightcopy (Sn-82, 8) // 3,456.78
Result := Rightcopy (Rlstr, 4) // 'py '
Result := Rightcopy (Rlstr, 4, true) // 'Copy'
Sa-5 : Alpha 5
Fin-5 : Financial 5
Sn-82 : Numeric 8.2 Format '999,999.99'
Rlstr : Realstring
Result : Realstring
code
Sa-5 := 'abcd'
Fin-5 := -3
Sn-82 := 123456.78
Rlstr := 'Demo RightCopy '
Result := Rightcopy (Sa-5, 2) // 'd '
Result := Rightcopy (Sa-5, 2, true) // 'cd'
Result := Rightcopy (Sa-5, 5, true) // 'abcd', copies only the 4 avaialble characters
Result := Rightcopy (Sa-5, -2) // Rejected by compiler
Result := Rightcopy (Sn-82, 4) // 6.78
Result := Rightcopy (Sn-82, 8) // 3,456.78
Result := Rightcopy (Rlstr, 4) // 'py '
Result := Rightcopy (Rlstr, 4, true) // 'Copy'