Selecting User Function

A function determines how a block will be calculated. A function should be written in a Fore unit and should have the following structure:

Public Function <Function name>([Additional parameter,]Paramarray parameters: Array Of Variant): Variant;

Where:

To get a function example, see the User Function Example section.

A user function can be selected on the Block Parameters page in the function block editing wizard:

To select a user function:

  1. Select a unit with the function or an assembly containing a unit with the function in the Unit drop-down list. The unit and assembly should be written in the Fore language.

  2. Select the user function in the Function drop-down list. The list contains only the unit functions that have the required signature.

  3. If custom parameters are determined in the function, set their values in the Additional Parameter Values box. If there are several parameters, their values should be entered via comma. String parameters should be entered in quotation marks.

  4. Check if function parameters are set correctly. Click the Check Syntax button. If everything is set up correctly, the appropriate message appears, otherwise an error message appears.

As a result, the user function is selected that is calculated by the block.

User Function Example

The example shows executing a DBMS command, which identifier is sent as a custom parameter.

To execute the example, add links to the Db, Metabase, Ui system assemblies.

Public Function callDBCommand(Command: String; Param: Array Of Variant): Variant;
Var
    comInst: ISQLCommandInstance;
Begin
    
If WinApplication.ConfirmationBox("Calculation may take a long time. Continue?"Then
        comInst := MetabaseClass.Active.ItemById(Command).Open(
NullAs ISQLCommandInstance;
        comInst.Execute;
    
End If;
    
Return 0;
End Function callDBCommand;

See also:

Inserting and Setting Up Function Blocks