ICalcAlgorithm.FindFormulas

Syntax

FindFormulas(FindInfo: IMsFormulaInfo): IAlgoFindFormulaResults;

Parameters

FindInfo. Search parameters.

Description

The FindFormulas method searches for formulas according to the specified parameters.

Comments

To set search criteria, use the CreateFormulaFindInfo property.

Example

Executing the example requires that the repository contains a calculation algorithm with the ALGO identifier. A calculation block is created and set up in the calculation algorithm, and a cube with the STD_CUBE identifier is used as data source. The cube structure has a dimension with the CITY identifier.

Add links to the Algo, Cubes, Dimensions, Metabase, Ms system assemblies. Add a link to the assembly required to work with the calculation algorithm.

Sub UserProc;
Var
    Mb: IMetabase;
    Alg: ICalcAlgorithm;
    FindInfo: IMsFindFormulaInfo;
    Factory: IDimSelectionSetFactory;
    DimSS: IDimSelectionSet;
Begin
    Mb := MetabaseClass.Active;
    Alg := CalcObjectFactory.CreateCalcObject(Mb.ItemById("ALGO"), TrueAs ICalcAlgorithm;
    Factory := New DimSelectionSetFactory.Create;
    DimSS := Factory.CreateDimSelectionSet;
    DimSS.Add(Mb.ItemById("CITY").Open(NullAs IDimInstance).SelectElement(0False);
    // Search conditions
    FindInfo := Alg.CreateFormulaFindInfo;
    FindInfo.Stub := Alg.Stubs.FindByKey(Mb.GetObjectKeyById("STD_CUBE"));
    FindInfo.Selection := DimSS;
    FindInfo.VarKind := MsVariableKind.Input;
    // Search and view results
    ShowAlgFindResults(Alg.FindFormulas(FindInfo));
End Sub UserProc;

Sub ShowAlgFindResults(Results: IAlgoFindFormulaResults);
Var
    Result: IAlgoFindFormulaResult;
    Block: IAlgoCalcBlockFindFormulaResult;
    Branch: IAlgoBranchCondFindFormulaResult;
    Expr: IMsBranchConditionExpression;
    i, c: Integer;
Begin
    c := Results.Count;
    Debug.WriteLine("Formulas found: " + c.ToString);
    For i := 0 To c - 1 Do
        Result := Results.Item(i);
        If Result Is IAlgoCalcBlockFindFormulaResult Then
            Block := Result As IAlgoCalcBlockFindFormulaResult;
            Debug.WriteLine("Block name: " + Block.CalcObject.Name);
            Debug.WriteLine("Formula key: " + Block.FormulaKey.ToString + " " + Block.ChainModel.Name);
        Elseif Result Is IAlgoBranchCondFindFormulaResult Then
            Branch := Result As IAlgoBranchCondFindFormulaResult;
            Debug.WriteLine("Branch: " + Branch.Branch.Name);
            Debug.WriteLine("Case: " + Branch.BranchCase.Name);
            If Branch.BranchCondition Is IMsBranchConditionExpression Then
                Expr := Branch.BranchCondition As IMsBranchConditionExpression;
                Debug.WriteLine("Condition: " + Branch.BranchCondition.Key.ToString + " " + Expr.Expression.AsString);
            End If;
        End If;
        Debug.WriteLine("-------");
    End For;
End Sub ShowAlgFindResults;

After executing the example the formulas are searched that contain terms based on elements of the specified data source dimension. The CITY dimension will have the first element selected. Information about found formulas will be displayed in the development environment console.

See also:

ICalcAlgorithm