Siebel eScript Language Reference > Methods Reference > Conversion Methods >

Evaluate Expression Method


The Evaluate Expression method evaluates the value that the expression argument contains. It returns the value that it evaluates in the expression argument. If the expression argument is a string, then this method attempts to interpret the string as if it is JavaScript code. If this method:

  • Interprets the string. It returns the value in the expression argument.
  • Cannot interpret the string. It returns the following value:

    undefined

If the expression is not a string, then this method returns the value that exists in the expression argument. For example, calling eval(5) returns the value 5.

Format

eval(expression)

Table 99 describes the arguments for the Evaluate Expression method.

Table 99. Arguments for the Evaluate Expression Method
Argument
Description

expression

The expression that this method must evaluate.

Example

The following example describes the result of using the Evaluate Expression method on different types of expressions. This method does the following work:

  • Interprets the string in the test[0] variable because it can interpret this string as a JavaScript statement.
  • Does not interpret the string in the test[1] variable or the test[3] variable because it cannot interpret either string as a JavaScript statement. It returns a value of undefined for each of these variables.

This example includes the following code:

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

Siebel eScript Language Reference Copyright © 2018, Oracle and/or its affiliates. All rights reserved. Legal Notices.