Brilliant Database Software - Home
Database software - Online Help System

Online Help System

Back to Brilliant Database Web-Site | Write to Support | Help Index

User Functions

table border="0" width="100%" cellspacing="0" cellpadding="4" bgcolor="#00000077">
User Functions


User Function is a script that can be executed from other scripts. For example, if you use a set of actions in several scripts, you can create a User Function containing these actions and call this function when you need.

User Functions can accept arguments and return the result of their work to a specified variable.

For example, you can create a User Function that calculates a complicated formula basing on some input data and returns the result to a variable. You can also record specified values to specified fields of a selected database record.

Using User Functions

Here is an example of simplifying the script described in Script Designer using a User Function:

First the script asks the user to enter the value of the [$quantity] variable that should exceed 0, then it increases the value of the [Order Total] field of the current folder by the entered value.

Let's replace this part of the script with a User Function:

Creating a New User Function

To create a new User Function, click User Functions > Create New... or right-click the User Functions tree and select Create New...:


Enter the name of the new User Function. For example, ChangeQuantity.

Click Ok to open the User Functions editor:

Editing User Functions

Editing a script in User Functions is similar to editing an ordinary script. See the Script Designer section for more information.

As noted above, a User Function can accept arguments and return values to a variable. To set a User Function, click the UF Setup... button or click User Function Properties... in the menu:


User Function Properties

  • Name - specify the function name;
  • Argument Name (1, 2, 3) - specify names of arguments where input variables will be recorded;
  • Description (1, 2, 3) - argument description;
  • Function returns value) - select this check box if you want the function to return its value. You can use the text box on the right to describe the value.

If you change the User Function properties as shown on the illustration, predefined variables will appear in the script tree of the UF editor:

You should record the result of the User Function to the [$result] variable at the end of the script.

We'll create a User Function using these variables:

Click Ok to save the User Function.

Inserting a User Function to a script

To call a User Function from a script, click User Functions > Insert... or double-click the required function in the function tree.

A standard Select Action dialog box will open:

In the dialog box we can set values of the User Function (default, text) and specify the variable where the action result will be saved ([$new_total]).

Thus, the script containing a User Function will look like this:

  • In line 2 we call the ChangeQuantity user function and record its result to the [$new_total] variable.
  • Line 3 shows the value of the [$new_total] variable.

All topics in the "About Scripts" section: