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

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. Refer to "Code Blocks" in the Programmer's Guide for more information on code blocks.
Examples
This example uses SEval() to extract the street number from a string containing the complete street address:
X#
LOCAL cStreetNumber AS STRING
LOCAL cAddress AS STRING
cStreetNumber := NULL_STRING
cAddress := "1209 West Golden Lane"
SEval(cAddress, ;
                {|c| cStreetNumber += ;
                If(IsDigit(Chr(c)), Chr(c), NULL_STRING)})
? cStreetNumber                                                // 1209
See Also