Adding a Function to the Script Library

The Script Library is a collection of functions, which can be called from any report or Viewsheet with access to the Library. To add a new function to the library, follow the steps below.

Note: The Script Library is independent of any report or Viewsheet. You do not need to open a report or Viewsheet in order to access the Script Library.

1. Click the 'New' button in the Style Studio toolbar. This opens the 'New Asset' dialog box.

2. In the 'New Asset' dialog box, select the 'Component' node in the right panel.

3. In the left 'Types' panel, select 'Script Function', and click 'OK'.

 

4. This opens the new script for editing, and displays the Properties and Functions panels as an aid to composing the script.

5. Write the desired script, beginning with “function” keyword.

 

Since JavaScript does not support type dec­laration, parameters are not qualified with types.

Any parameters (e.g., “col”) should be placed in a comma-sepa­rated list inside the parentheses that follow the function name. These parameters can then be used inside the function body.

6. Click the 'Save' button in the Style Studio toolbar.

 

A function name should begin with an uppercase or lowercase letter, followed by letters, digits, or '_'. No spaces or other special characters should be used.

7. When prompted, enter a valid name for the function, and click 'OK'. This saves the script into the Script Library.

Note in the above function that the property “table” is not qualified by an element ID (e.g., “Table1.table”). Functions are scoped dynamically (see Function Scope); therefore, the property “table” refers to whichever Table element called the tableTotal() function. You can therefore call this tableTotal() function from within any table element to operate on that particular table element.

See Also

Editing a Function in the Script Library, to edit an existing function.

Functions, in Report Scripting, for details of the JavaScript function syntax.

Functions, in Dashboard Scripting, for details of the JavaScript function syntax.

<< Script Library © 1996-2013 InetSoft Technology Corporation (v11.4) Editing a Function in the Script Library >>