Siebel eScript Language Reference > Siebel eScript Commands > Conversion Methods >
parseInt() Method
This method converts an alphanumeric string to an integer number. Syntax
parseInt(string [,radix])
|
|
string |
The string to be converted |
radix |
The radix, or base of the number system, in which the integer return value is expressed; for example, if radix is 8, then the return value is expressed as an octal number. |
Returns
An integer number; if string cannot be converted to a number, the special value NaN is returned. If radix is not provided or is zero, then radix is assumed to be 10, with the following exceptions:
- If string begins with the character pairs 0x or 0X, a radix of 16 is assumed.
- If string begins with zero and a valid octal digit (0-7), a radix of 8 is assumed.
Usage
White-space characters at the beginning of the string are ignored. The first nonwhite-space character must be either a digit or a minus sign (-). Numeric characters in string are read. Reading stops at the first non-numeric character. The result is converted into an integer number. Characters including and following the first non-numeric character are ignored. CAUTION: When the passed string contains a leading zero, such as in "05," the number is interpreted as on octal, as it is in other eScript contexts. Parameters that are interpreted as invalid octals, such as "08" and "09," will generate a return value of zero.
Example
The following code fragment returns the result -234 : var num = parseInt(" -234.37 profit");
|