Siebel eScript Language Reference > Siebel eScript Language Overview > Functions in Siebel eScript >

Function Scope in Siebel eScript


Functions are global in scope and can be called from anywhere in a script within the object in which it has been declared. Think of functions as methods of the global object. A function may not be declared within another function so that its scope is merely within a certain function or section of a script.

The following two code fragments perform the same function. The first calls a function, SumTwo(), as a function, and the second calls SumTwo() as a method of the global object.

// fragment one
function SumTwo(a, b)
{
   return (a + b)
}

TheApplication().RaiseErrorText(SumTwo(3, 4));


// fragment two
function SumTwo(a, b)
{
   return (a + b)
}

TheApplication().RaiseErrorText(global.SumTwo(3, 4));

In the fragment that defines and uses the function SumTwo(), the literals, 3 and 4, are passed as parameters to the function SumTwo() which has corresponding parameters, a and b. The parameters, a and b, are variables for the function that hold the literal values that were passed to the function.

Siebel eScript Language Reference