Configuring User-Defined Functions

Monarch Classic allows you to create your own customized functions, called user-defined functions, which you can then use in calculated field, filter, and find expressions. User-defined functions can be created from a combination of Monarch Classic's "intrinsic" functions (i.e., the functions built into Monarch Classic, such as LSplit), constants (e.g., text strings, dates, and numbers), and operators. You can then add a list of parameters to pass to the function, and even define different forms of the function, with different sets of parameters. You could, for example, create a user-defined function to format a customer number to your specifications, return a drive letter from a file path, and anything else that you may find useful.

User-defined functions are configured via the User-Defined Function Definition dialog, and appear in the Functions list on the Formula tab of the Filter Definition dialog, the Formula tab of the Field Properties dialog for a calculated field, and the Find Expression Builder, so that they will be available for use in filter, find, and calculated field expressions.

To find out more about user-defined functions, see the User-Defined Functions Overview.

  1. Select Functions from the Table Design ribbon.

  2. Select Click to add a new Function to display the User-Defined Function Definition window.

  3. In the Name field, enter a name for the user-defined field, and then click on the green check icon to accept. The name you specify will be added to the Functions list on the when defining filters and calculated fields.

  4. In the Description field, enter a description of what the function will do. This description will appear at the bottom of the Formula tab when configuring a filter, search, or calculated field expression.

    Note: You can enable syntax highlighting for parameters within the description by using a HTML-style opening and closing tag for a word, as it relates to a parameter. For example, if a function has two parameters, startdate and enddate, you can make the words in the description appear in bold when the parameter is the "live" part of the expression when the function is being used. The following text would show the words "starting date" and "ending date" in bold as the function parameters are populated (this assumes startdate is parameter 1 and enddate is parameter 2):

    "Shows the age in years, based on a given <1>starting date</1> and <2>ending date</2>."

  5. Click the Add button to display the Edit Form - Function dialog. With this dialog, you can specify the parameters and expression for the user-defined function. If you want to create different forms of the function, use the Add button to create a new form.

  6. If the function requires one or more parameters, then enter the name(s) of the parameter(s) and specify the data type. The order of the rows in the grid is significant because it reflects the order of the parameters in the parameter list. Parameters may be re-ordered by selecting and dragging the rows in the grid. They can be deleted by selecting their entire row or rows in the grid, then pressing Delete.

  7. Specify the Return Type for the function, either character, date/time or numeric.

  8. Use the Formula Tab to enter your expression. If you specified any parameters, they will be available in the left hand Parameters box, sorted alphabetically.

  9. Once your expression is complete, you can either click OK to return to the User-Defined Function dialog, or use the Parameters Tab to test the expression. Click OK when you are satisfied with your function.

  10. Under the Categories heading, select the appropriate check box(es) to specify the desired category (or categories) for the user-defined function to appear under in the Formula tab of the Expression editor.

  11. It may be very useful to add a comment to the user-defined function to explain its workings and purpose, especially if other users will be using it as well. To do so, click the Comment button and enter your comment into the drop-down provided.

  12. Click OK to save the changes and close the dialog (or click Cancel to close the dialog without saving any changes).




© 2024 Altair Engineering Inc. All Rights Reserved.

Intellectual Property Rights Notice | Technical Support