Creating User Defined Functions

How to:

You are able to create your own functions by using the Define Function Wizard. The Define Function Wizard assists in the creation of a user function. The created functions can later be retrieved through the Function Arguments dialog box using the Retrieve User Functions button. Click Retrieve User Functions so that your created functions will be available for use.


Top of page

x
Procedure: How to Create a User Defined Function

To create a user defined function:

  1. Create a new procedure.

    The Add Procedure dialog box opens.

  2. Name the procedure and click Define Function from the Create With drop-down menu, as shown in the following image.

    Note: You can also select Define Function from the component connector, however, the user functions created through this method will only be applicable to that specific procedure. User Functions created through the Add Procedure dialog box will be available for use by all procedures within the APP PATH.

    The Define Function Wizard opens, as shown in the following image.

  3. Click Next.

    The Name part of the Define Function Wizard is displayed, as shown in the following image.

  4. Enter a name and description for the function and click Next.

    The Parameters section of the Define Function Wizard is displayed, as shown in the following image.

  5. Click the Add new item button to add new parameters to the function.

    You can rename the parameters by double-clicking on the name column. For each parameter, clicking the ellipsis button in the Format column will open the Format dialog box, allowing you to edit the format of that parameter. Double-clicking in the Description column for each parameter will allow you to edit the description for parameter.

  6. Click Next.

    The Defined Fields section of the Define Function Wizard is displayed. One defined field (with the same name as your function) is already entered, as shown in the following image.

    A function is comprised of expressions that returns a value to the caller of the function.

  7. Click the Add new item button if you want to add more defined fields.

    You can rename the fields by double-clicking on the name column. For each field, clicking the ellipsis button in the Format column will open the Format dialog box, allowing you to edit the format of that field. Clicking the ellipsis button in the Expression column will open a dialog where you can edit what the function will do.

    Note: The last defined field must have the same name as the function. This is why one defined field is already entered with the same name as the function. If multiple expressions are present, then the defined field with the same name as the function must be in the last position, as shown in the following image. If no defined field has the same name as the function or if the defined field is not in the last position, you will be unable to progress to the next window.

  8. Click Next.

    The Complete the Define Function Wizard window is displayed. The function, as well as its parameters and logic, are displayed before completion, as shown in the following image.

  9. Click Finish to create the function.

    The Define Function Wizard opens to a new window, as shown in the following image.

    If there are no more functions you want to create, clicking OK will close the Wizard with all functions created.

  10. If you want to create more functions, click New to bring up the Define Function Wizard again, allowing you to create another function.

    This can be done as many times as needed, allowing you to create multiple functions in the procedure, without having to exit and repeat certain steps.

    Select a function and click Edit to open the Define Function Wizard. Here you can change any part of the already created function by going through each window.

    Select a function and click Delete to delete the function.


Top of page

x
Procedure: How to Retrieve a User Defined Function
  1. Create a procedure and user defined function to be used later by a report.
  2. Create a report that will utilize the function you created.
  3. Click the Define button, as shown in the following image.

    The Define tool opens.

  4. Click the Functions button.

    The Function Arguments dialog box opens.

    Note: The Function Arguments dialog box can also be accessed from the Report Options Compute tab and the Expression Builder.

  5. Click the Retrieve User Functions button, as shown in the following image.

    The functions you created using the Define Function Wizard are available for use, as shown in the following image.

    Once the user functions have been loaded, the Retrieve User Functions button becomes the Refresh User Functions button. Click this button to refresh your user functions and show any new user functions that have been added.


WebFOCUS