Execute a code block for each of the individual characters in a string.
Namespace:
XSharp.RT
Assembly:
XSharp.RT (in XSharp.RT.dll) Version: 2.7
Syntax FUNCTION SEval(
cString AS USUAL := NIL,
cbBlock AS USUAL := NIL,
nStart AS USUAL := NIL,
nCount AS USUAL := NIL
) AS STRING
public static string SEval(
Usual cString = null,
Usual cbBlock = null,
Usual nStart = null,
Usual nCount = null
)
Request Example
View SourceParameters
- cString (Optional)
- Type: Usual
The string to scan. - cbBlock (Optional)
- Type: Usual
The code block to execute for each character encountered. - nStart (Optional)
- Type: Usual
The starting character.
A negative value starts from the end.
The default value is 1 if <nCount> is positive and
The length of <cString> if <nCount> is negative.
- nCount (Optional)
- Type: Usual
The number of characters to process from <nStart>.
A negative value steps downward.
The default is all characters to the end of the string.
Return Value
Type:
String
A string of characters that have been processed by the code block.
Remarks
SEval() is a character function that evaluates a code block once for each character in a string, passing the ASCII value and the character index as arguments.
The return value of the code block is ignored.
All characters in <cString> are processed unless either the <nStart> or the <nCount> argument is specified.
Examples
This example uses SEval() to extract the street number from a string containing the complete street address:
1LOCAL cStreetNumber AS STRING
2LOCAL cAddress AS STRING
3cStreetNumber := NULL_STRING
4cAddress := "1209 West Golden Lane"
5SEval(cAddress, ;
6 {|c| cStreetNumber += ;
7 If(IsDigit(Chr(c)), Chr(c), NULL_STRING)})
8? cStreetNumber
See Also