Click or drag to resize

SubStr3 Function

X#
Extract a substring from a string, using strong typing and three required arguments.

Namespace:  XSharp.Core
Assembly:  XSharp.Core (in XSharp.Core.dll) Version: 2.21
Syntax
 FUNCTION SubStr3(
	cTarget AS STRING,
	dwStart AS DWORD,
	dwLen AS DWORD
) AS STRING
Request Example View Source

Parameters

cTarget
Type: String
The string from which to extract a substring.
dwStart
Type: DWord
The starting position in cTarget. Since this argument is a WORD, it cannot be negative.
dwLen
Type: DWord
The number of characters to extract.
If omitted, the substring begins at dwStart and continues to the end of the string.
If dwLen is greater than the number of characters from dwStart to the end of cTarget, the extra is ignored.

Return Value

Type: String
The substring.
If the substring is not found, it returns a NULL_STRING.
Remarks
Substr3() is a typed version of Substr() and requires three arguments. See Substr() for details.
Examples
These examples extract the first and last name from a variable:
X#
1LOCAL cName AS STRING
2cName := "Biff Styvesent"
3? Substr3(cName, 1, 4)                // Biff
4? Substr3(cName, 6, 9)                // Styvesent
5? Substr3(cName, 6, 3)                // Sty
6? Substr3(cName, SLen(cName) + 2, 5)    // null string
See Also