Siebel eScript Language Reference > Using Siebel eScript > Coding with Siebel eScript >

Passing a Value to a Function


This topic describes how to write code that passes a value to a subroutine or a function through a variable or through a reference.

Passing a Value Through a Variable

Siebel eScript can pass a value to a function through a variable. This variable retains the value that it contained before Siebel eScript passes it even though the subroutine or function might modify the passed value. The following example includes this configuration:

var VariableA = 5;
var VariableB = ReturnValue(VariableA);

function ReturnValue(VariableC)
{
   VariableC = 2 * VariableC;
   return VariableC ;
}

The following occurs in this example:

  • VariableA equals 5 and VariableB equals 10.
  • VariableC contains a value only while the ReturnValue function runs.
  • VariableC does not contain a value after the ReturnValue function finishes.
  • Siebel eScript passes VariableA as a parameter to the ReturnValue function and it manipulates this value as VariableC.
  • VariableA retains the value that it contained before Siebel eScript passed it.

Passing a Value Through a Reference

Siebel eScript can pass a variable to a subroutine or a function through a reference. However, you use a variable to pass a value for most methods. Each method determines if it can receive a value from a variable or a reference.

A subroutine or function can modify the value. The following example includes this configuration:

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

function ReturnName(VariableB)
{
   var VariableC = VariableB.name;
   VariableB.name = "Vijay";
   return VariableC
}

The following occurs in this example:

  • Siebel eScript passes VariableA to the ReturnName function through a reference.
  • VariableB receives a reference to the object, but it does not receive a copy of this object.
  • VariableB can reference every property and method of VariableA.
  • The ReturnName function modifies the value in VariableB.name to Vijay. The value in VariableA.name also becomes Vijay.
  • The Return statement passes a value back to the function that calls it. Siebel CRM does not run any code in a function that follows the Return statement. For more information, see Return Statement of a Function Object.
Siebel eScript Language Reference Copyright © 2013, Oracle and/or its affiliates. All rights reserved. Legal Notices.