Click or drag to resize

Right Function

Return a substring beginning with the rightmost character.

Namespace:  XSharp.Core
Assembly:  XSharp.Core (in XSharp.Core.dll) Version: 2.5
Syntax
 FUNCTION Right(
	cString AS STRING,
	dwCount AS DWORD
) AS STRING

Parameters

cString
Type: String
The string from which to extract characters.
dwCount
Type: UInt32
The number of characters to extract.

Return Value

Type: String
The rightmost <dwCount> characters of <cString>.
If <dwCount> is 0, Right() returns a NULL_STRING.
A negative value is not allowed since a WORD cannot be negative.
If <dwCount>  larger than the length of the string, Right() returns <cString>.
Remarks
Right() is the same as Substr(<cString>, -<wCount>).
For example, Right("ABC", 1) is the same as Substr("ABC", -1).  Right() is related to Left(), which extracts a substring beginning with the leftmost character in <cString>. The Right(), Left(), and Substr() functions are often used with both the At() and RAt() functions to locate either the first and/or the last position of a substring before extracting it.
Examples
This example shows the relationship between Right() and Substr():
X#
1? Right("ABCDEF", 3)                // DEF
2? Substr("ABCDEF", 3)                // CDEF
3? Substr("ABCDEF", -3)                // DEF
This example extracts a substring from the end of another string, up to the last occurrence of a comma:
X#
1LOCAL cName AS STRING
2cName := "James, William"
3? Right(cName, SLen(cName) - RAt(",", cName) -1)    // William
See Also