Defining user-defined functions

Although you define global functions in the Function painter and object-level functions in the painter for a specific object, in both cases you define and code the function in a Script view.

When you add a new function, a Prototype window displays above the script area in the Script view. The fields in the Prototype window are in the same order as the function’s signature:

Figure 7-1: Defining a function prototype

Shown is the Script View. Selected in the second list box at top is the function o f underscore add, including the function’s prototype or syntax. Below is the Prototype window with text fields labeled Access, Return Type, and Function Name, and then drop downs for Pass By, Argument Type and Argument Name. At bottom is the script area.

The following sections describe each of the steps required to define and code a new function:

  1. Opening a Prototype window to add a new function.

  2. Defining the access level (for object-level functions).

  3. Defining a return type.

  4. Naming the function.

  5. Defining arguments.

  6. Defining a THROWS clause.

  7. Coding the function.

  8. Compiling and saving the function.