Bookshelf Home | Contents | Index | Search | PDF | ![]() ![]() ![]() ![]() |
Siebel eScript Language Reference > Siebel eScript Commands > The Global Object >
eval() Method
This method returns the value of its parameter, which is an expression.
Syntax
eval(expression)
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. Note that the string expression in the
test[0]
variable is evaluated because it can be interpreted as a JavaScript statement, but the string expressions intest[1]
andtest[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.
Bookshelf Home | Contents | Index | Search | PDF | ![]() ![]() ![]() ![]() |
Siebel eScript Language Reference Published: 18 April 2003 |