Siebel eScript Language Reference > Siebel eScript Commands > Conversion Methods >
eval() Method
This method returns the value of its parameter, which is an expression. Syntax
eval(expression)
|
|
expression |
The expression to be evaluated |
Returns
The value of expression. Usage
This method evaluates whatever is represented by expression. If expression is a string, the interpreter tries to interpret the string as if it were JavaScript code. If successful, the method returns the value of expression. If not successful, it returns the special value undefined . If the expression is not a string, expression is returned. For example, calling eval(5) returns the value 5. Example
This example shows the result of using the eval() method on several types of expressions. The string expression in the test[0] variable is evaluated because it can be interpreted as a JavaScript statement, but the string expressions in test[1] and test[3] are undefined. function clickme_Click () { var msgtext = ""; var a = 7; var b = 9; var test = new Array(4); var test[0] = "a * b"; var test[1] = toString(a * b); var test[2] = a + b; var test[3] = "Strings are undefined."; var test[4] = test[1] + test[2];
for (var i = 0; i < 5; i++) msgtext = msgtext + i + ": " + eval(test[i]) + "\n"; TheApplication().RaiseErrorText(msgtext);
Running this code produces the following result: 0: 63 1: undefined 2: 16 3: undefined 4: undefined
|