CharPos Function | |
Return a character based on its position in a string.
Namespace:
XSharp.Core
Assembly:
XSharp.Core (in XSharp.Core.dll) Version: 2.19
Syntax FUNCTION CharPos(
cString AS STRING,
wPosition AS DWORD
) AS STRING
public static string CharPos(
string cString,
uint wPosition
)
Request Example
View SourceParameters
- cString
- Type: String
The string that you want to extract a character from. - wPosition
- Type: DWord
The position of the character within cString.
Return Value
Type:
String
The character located at the specified position.
Remarks
CharPos(
cString,
wPosition) extracts a substring from the specified string for a length of one character. Functionally, it is the same as Substr(
cString,
wPosition, 1).
This example extracts single letters from a name and displays them individually:
1FUNCTION SayName()
2 LOCAL siCount AS SHORTINT
3 LOCAL cName := "Biff Styvesent"
4 FOR siCount := 1 UPTO Len(cName)
5 ?? CharPos(cName, siCount)
6 NEXT
Examples See Also