The scope of a global variable is too large to meet the business requirement

The scope of a global variable is too large to meet

This preview shows page 48 - 51 out of 334 pages.

The scope of a global variable is too large to meet the business requirement and often results in a variable whose lifecycle is not clear. Instead of using a global variable, it is recommended that you configure Siebel CRM to pass an object as a parameter to a function so that you can control the scope of the parameter. If you are considering using a global variable, then you must consider this usage carefully. If you use a global variable, then do so only rarely and document it thoroughly. Example of Declaring Local and Global Variables The following example includes local and global variables: var globalVariable = 1; function Function1() { var localVariable1 = 1; var localVariable2 = 3; Function2(d); } function Function2(e) { var localVariable3 = 2 ... } This example illustrates the following concepts: The globalVariable variable is global to the object in which it is declared because it is declared outside of a function. Typically you declare all global variables in a general declarations section. To create a local variable, you declare it in a function. The following variables are local because this example declares them in a function: localVariable1 localVariable2 localVariable3 This example cannot use localVariable3 in Function1 because it is not defined in that function. This example uses the d variable in Function1. It uses the e parameter to pass the d variable to Function2. The following code includes variables that are available to Function1 and Function2: Function1(): globalVariable, localVariable1, localVariable2 Function2(): globalVariable, localVariable3, e
Image of page 48
Using Siebel eScript Coding with Siebel eScript Siebel eScript Language Reference Version 8.1, Rev. A 49 Declaring a Variable This topic describes how to declare a variable. To declare a variable Use the var keyword. For example: var perfectNumber; You can save a value in a variable when you declare it. For example: var perfectNumber = 28; Declaring a Variable In a Statement Block If you declare a variable in a statement block in a method, then you can reference that variable anywhere in the method, including a statement block in the method where you did not declare the variable. Determining the Data Type of a Variable To determine and set the data type of a variable, you can use the typeof operator. To determine the data type of a variable Use one of the following formats: var result = typeof variable var result = typeof(variable) To improve readability, you can place parentheses around the variable operand, which makes typeof look like the name of a function rather than an operator keyword. Using these parentheses is functionally the same as not using them. They have no impact on program execution. Immediately after Siebel CRM encounters one of these code lines, it sets the contents of the variable to one of the following string values: boolean buffer function object number string undefined
Image of page 49
Siebel eScript Language Reference Version 8.1, Rev. A Using Siebel eScript Coding with Siebel eScript 50 Passing a Value to a Function
Image of page 50
Image of page 51

You've reached the end of your free preview.

Want to read all 334 pages?

  • Summer '16
  • Oracle
  • Type system, Siebel, Siebel eScript

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern

Stuck? We have tutors online 24/7 who can help you get unstuck.
A+ icon
Ask Expert Tutors You can ask You can ask ( soon) You can ask (will expire )
Answers in as fast as 15 minutes
A+ icon
Ask Expert Tutors