Working with Global Variables

Global variables are accessible to all ProcScript in an application's components, and to global ProcScripts that use the same library or the system library.

Note:  Global variables are at risk of being overwritten by multiple components. It is usually preferable to use component and local variables, rather than global variables.

  1. To open the global variable editor:
    1. Click the More Editors and choose Global Variables.
    2. Select or create a library to hold the variables.
  2. To create a new global variable:
    1. Click New and enter the Variable Name and optional Description.
    2. Set the properties for the Data Type and Display Format.

      For more information, see Display Formats.

    Global Variables Library Editor

    Global variable editor showing a definition

  3. To delete a variable, select it and choose Edit >Delete Variable.
  4. To save new or modified variables, choose File> Save.

    Alternatively, click OK to save the definition and close the editor.

    Global variables are automatically compiled when you save them.

  5. To reference a global variable in ProcScript,
    1. Prefix the name with $$.

      Note:  References to variables are not case sensitive.

    2. Specify its parent library in the component's Library property or set $variation in ProcScript.

    Note:  Global variables of Data TypeHandle cannot be used for accessing operations. Instead, use a component handle on a service. For more information, see Handles.

    In a large complex application, the risk of several components overwriting the value of global variables increases. When using these variables it is important to clear them when they are no longer required.

    For example, for a global variable defined as SALES_TAX, it can be referenced as $$SALES_TAX.

    $variation = "MyLib" ; specify the parent library
    $$SALES_TAX = SUBTOTAL.ORDER * <TAX_RATE> ; assign value to global variable
    TOTAL = SUBTOTAL + $$SALES_TAX
    $$SALES_TAX = "" ; clear global variable

Related Topics