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

Complex Objects in Siebel eScript

Variables can be passed as parameters to subroutines and functions in two ways:

  • By value. A variable passed by value retains its value prior to being passed, even though the passed value may change during processing within the subroutine or function. The following fragment illustrates:

    var a = 5;
    var b = ReturnValue(a);

    function ReturnValue(c)
       c = 2 * c;
       return c ;

    After this script runs, a = 5 and b = 10. However, c has value only during the execution of the function ReturnValue, but not after the function has finished execution. Although a was passed as a parameter to the function, and that value is manipulated as local variable c, a retains the value it had prior to being passed.

  • By reference. Complex objects are objects that are passed by reference. When a variable is passed by reference, a reference to the object's data is passed. A variable's value may be changed by the subroutine or function to which it is passed, as illustrated by the following fragment:

    var AnObj = new Object; = "Joe";
    AnObj.old = ReturnName(AnObj)

    function ReturnName(CurObj)
       var c =; = "Vijay";
       return c

    When AnObj is passed to the function ReturnName(), it is passed by reference. CurObj receives a reference to the object, but it does not receive a copy of the object.

    With this reference, CurObj can access every property and method of AnObj, which was passed to it. During the course of the function executing, is changed to "Vijay" within the function, so also becomes "Vijay."

Each method determines whether parameters are passed to it by value or by reference. For the large majority of methods, parameters are passed by value.

Siebel eScript Language Reference