Click or drag to resize

SEval Function

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.5
Syntax
 FUNCTION SEval(
	cString AS USUAL,
	cbBlock AS USUAL,
	nStart AS USUAL,
	nCount AS USUAL
) AS STRING

Parameters

cString
Type: Usual
The string to scan.
cbBlock
Type: Usual
The code block to execute for each character encountered.
nStart
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
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:
X#
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                        // 1209
See Also