Right Function | |
Return a substring beginning with the rightmost character.
Namespace:
XSharp.Core
Assembly:
XSharp.Core (in XSharp.Core.dll) Version: 2.21
Syntax FUNCTION Right(
cString AS STRING,
dwCount AS DWORD
) AS STRING
public static string Right(
string cString,
uint dwCount
)
Request Example
View SourceParameters
- cString
- Type: String
The string from which to extract characters. - dwCount
- Type: DWord
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():
1? Right("ABCDEF", 3)
2? Substr("ABCDEF", 3)
3? Substr("ABCDEF", -3)
This example extracts a substring from the end of another string, up to the last occurrence of a comma:
1LOCAL cName AS STRING
2cName := "James, William"
3? Right(cName, SLen(cName) - RAt(",", cName) -1)
See Also