Siebel eScript Language Reference > Siebel eScript Language Overview > Data Types >

Automatic Type Conversion


Conversion occurs automatically during concatenation involving both strings and numbers, and is subject to the following rules:

The following examples illustrate these automatic conversions:

"dog" + "house" == "doghouse" // two strings are joined
"dog" + 4 == "dog4   " // a number is converted to a string
4 + "4" == "44   "// a number is converted to a string
4 + 4 == 8   // two numbers are added
23 - "17" == 6   // a string is converted to a number

However, to make sure that your code does not break if the conversion is not performed, use one of the casting functions to perform the appropriate conversion. (For details on these functions, read Conversion or Casting Functions.) The following example accepts string input and converts it to numeric to perform arithmetic:

var n = "55";
var d = "11";
divide it by:");
var division = Clib.div(ToNumber(n), ToNumber(d));

To specify more stringent conversions, use the parseFloat() Method of the global object. Siebel eScript has many global functions to cast data as a specific type. Some of these are not part of the ECMAScript standard. Read parseFloat() Method.

NOTE:  There are circumstances under which conversion is not performed automatically. If you encounter such a circumstance, you must use one of the casting functions to get the desired result. For an explanation of casting functions, read Conversion or Casting Functions.


 Siebel eScript Language Reference 
 Published: 18 April 2003