Bookshelf Home | Contents | Index | PDF |
Siebel eScript Language Reference > Methods Reference > Data Querying Methods > Function ObjectA Function object contains the definition of a function that you define in Siebel eScript. It returns the code that you configure this function to return. For more information, see Return Statement of a Function Object. Format Afunction funcName( [arg1 [, ..., argn]] ) In format A you declare a function, and then call it in your code. It is the standard way to define a function. Format Bvar funcName = new Function([arg1 [, ..., argn,]] body ); In format B you explicitly create a function. If you use format B to create a function object, then Siebel CRM evaluates it each time it uses this function. This configuration is not as efficient as format A because Siebel CRM compiles a declared function only one time instead of evaluating it every time it uses the function. ArgumentsTable 103 describes the arguments for a function object. Example 1The following example uses format A to declare a function named AddTwoNumbers. It uses AddTwoNumbers as the name of the function: function AddTwoNumbers (a, b) Example 2The following example uses format B to create a function named AddTwoNumbers. It uses the Function constructor to create a variable named AddTwoNumbers. The value of this variable is a reference to the function that the Function constructor creates: AddTwoNumbers = new Function ("a", "b", "return (a + b)"); Length Property of a Function ObjectThe length property returns the number of arguments that the function expects. FormatTable 104 describes the arguments for the length property.
Return Statement of a Function ObjectThe Return statement passes a value back to the function that called it. FormatTable 105 describes the arguments for the Return statement.
UsageSiebel CRM does not run any code in a function that occurs after a Return statement. If you define a return type for a custom function, then you must explicitly return a value of the same type that the function header specifies. All control paths must lead to a Return statement. Example 1The function in the following example returns a value that is equal to the number that Siebel CRM passes to it multiplied by 2, and then divided by 5: function DoubleAndDivideBy5(a) Example 2The following example does the following work:
|
Siebel eScript Language Reference | Copyright © 2018, Oracle and/or its affiliates. All rights reserved. Legal Notices. | |