substring Function (Windows CE 5.0)
Returns the substring of the first argument starting at the position specified in the second argument and the length specified in the third argument.
stringsubstring(string, number, number?)
Parameters
- string
A string. - number
A number specifying the start position. - number
[optional] A number specifying the length of the string to be returned.
Return Values
Returns the substring of the first argument starting at the position specified in the second argument and the length specified in the third argument.
Remarks
Each character in the string is considered to have a numeric position. The position of the first character is 1, the position of the second character is 2, and so on.
If the third argument is not specified, it returns the substring starting at the position specified in the second argument and continuing to the end of the string.
The following function call returns "234".
substring("12345",2,3)
The following function call returns "2345".
substring("12345",2)
The returned substring contains those characters for which the position of the character is greater than or equal to the rounded value of the second argument, and if the third argument is specified, less than the sum of the rounded value of the second argument and the rounded value of the third argument. The comparisons and addition used for the preceding follow the standard IEEE 754 rules; rounding is done as if by a call to the round function.
The following examples illustrate unusual cases.
substring("12345", 1.5, 2.6)
returns "234
"
substring("12345", 0, 3)
returns "12
"
substring("12345", 0 div 0, 3) returns ""
substring("12345", 1, 0 div 0) returns ""
substring("12345", -42, 1 div 0) returns "12345"
substring("12345", -1 div 0, 1 div 0) returns ""
Requirements
None.
See Also
Send Feedback on this topic to the authors