Defining a custom function
About this task
Procedure
- Select the Functions tab. In the Function tab, the list of standard functions is displayed. In addition, the Actions pane opens.
- To display the Custom Function dialog
box, choose from one of the following options:
- Right-click the Custom Functions node in the Functions tab and from the menu select Add New Custom Function... .
- In the Actions pane, select Add New Custom Function.
The Custom Function dialog box opens.
- In the Function Name field of the Custom
Function dialog box, enter a valid JavaScript name for your custom function. Note: This name must be unique for all custom functions in the current project. The name of the function is not case sensitive - the case of a character is not considered. For example the function name: Aaa is equivalent to the function name: AAA.
- Select a Return Type for your custom
function from one of the following options:
- string
- number
- boolean
- Define the parameters for your custom function. Repeat
the following steps for each parameter in your custom function:
- Click Add.
- In the Name field of the Parameters table, enter the name of the parameter and press the Return key.
- Select a Type for the parameter, from one
of the following options:
- string
- number
- boolean
- For more information about these datatypes, see Custom Function Parameter and Return Datatypes.
- Enter the source code for your custom function by following
these steps:
- Click Next.
- In the white area displayed between the braces enter the JavaScript code of your custom function.
- Click Compile. The syntax of the function will be checked and any errors reported. The location of the errors are highlighted in red in the source code.
- Fix any syntax errors and once the function compiles successfully, click OK and then Finish.
Results
Parent topic: Using Custom Functions and Lookup Tables