ICalcFunc.Procedure

Syntax

Procedure: String;

Description

The Procedure property determines a custom function.

Example

Executing the example requires that the repository contains a calculation algorithm with the ALGORITHM identifier and a unit with the MODULE identifier. The unit should contain a function named Func.

Add links to the Algo, Metabase system assemblies. Add links to the assemblies required for working with calculation algorithms.

Sub UserProc;
Var
    MB: IMetabase;
    Descr, MObjAlgo: IMetabaseObjectDescriptor;
    BlockFunc: ICalcFunc; 
    Algo, CalcObject: ICalcObject;
    List: ICalcObjectsList;
    CalcAlgo: ICalcAlgorithm;
    ObjectType: IMetabaseCustomClass;
Begin
    MB := MetabaseClass.Active;
    // Get calculation algorithm
    MObjAlgo := MB.ItemById("ALGORITHM");
    Algo := CalcObjectFactory.CreateCalcObject(MObjAlgo , True);
    CalcAlgo := Algo As ICalcAlgorithm;
    // Set object type - function block
    ObjectType := GetMetabaseHelper.GetCustomClassByEnum(BPClasses.Func_Block);
    Descr := GetMetabaseHelper.CreateObjectDescriptor(ObjectType.ClassId, ObjectType.Name, "", CalcAlgo.Descriptor, FalseFalseNullTrue);
    // Create a function block
    CalcObject := New CalcFuncClass.Create(Descr);  
    BlockFunc := CalcObject As ICalcFunc;
    // Set unit with function
    BlockFunc.Assembly := MB.ItemById("MODULE");
    // Set function that will be executed on block calculation
    BlockFunc.Procedure := "Func";
    // Set additional parameter value
    BlockFunc.SimpleParamValues := "10289";
    // Check syntax
    If BlockFunc.IsValid = False Then
        // Display error message
        Debug.WriteLine(BlockFunc.ErrorInfo.ErrorMessage);
    Else
        // Save function block
        CalcObject.SaveObject;
    End If;
    // Get list of calculation algorithm objects
    List := CalcAlgo.Items;
    // Add a created function block
    List.Add(CalcObject);
    // Save changes in calculation algorithm
    CalcAlgo.SaveObject;
End Sub UserProc;

After executing the example, a function block with the specified settings will be added in the calculation algorithm. The console displays the error message if function parameters are set incorrectly.

See also:

ICalcFunc