IMDCalculationInstance.FindElementEntries

Syntax

FindElementEntries(ElementKey: IMDCalculationFormulaElementKey): IMDCalculationFormulasIterator;

Parameters

ElementKey. Key of the element, which is used to search for element occurrences in formulas.

Description

The FindElementEntries method searches for element occurrences in formulas.

Comments

If search is successful, the method returns the iterator by formulas, into which the element is included. If no occurrence is found, the method returns Null.

Example

Executing the example requires a form, a button with the Button1 name on the form and the text editor named Memo1. The repository must also contain multidimensional calculation with the OBJMD identifier.

    Sub Button1OnClick(Sender: Object; Args: IMouseEventArgs);
    Var
        MB: IMetabase;
        MDInst: IMDCalculationInstance;
        Source: IMDCalculationSourceInstance;
        Slices: IMDCalculationSlicesInstance;
        Slice: IMDCalculationSliceInstance;
        Coord: IMatrixCoord;
        SourceElKey: IMDCalculationFormulaElementKey;
        Iterator: IMDCalculationFormulasIterator;
        i, j: Integer;
    Begin
        MB := MetabaseClass.Active;
        MDInst := MB.ItemById("OBJMD").Open(NullAs IMDCalculationInstance;
        Source := MDInst.Sources.Item(0);
        Slices := Source.Slices;
        Coord := Source.NewCoord;
        //Select first elements in all dimensions
        For i := 0 To Slices.Count - 1 Do
            Slice := Slices.Item(i);
            Coord.Item(i) := 0;
            Memo1.Lines.Add(The " + Slice.Name + " contain selected element " + Slice.Dimension.Elements.Name(Coord.Item(i)));
        End For;
        SourceElKey := Source.CoordToKey(Coord);
        SourceElKey.FactIndex := 0;
        Iterator := MDInst.FindElementEntries(SourceElKey);
        j := 0;
        While Not Iterator.Eof Do
            j := j + 1;
            Memo1.Lines.add(fact:  + iterator.Key.FactIndex.ToString);
            Iterator.Next;
        End While;
        Memo1.Lines.add(Number of occurrences by coordinate:  + j.ToString);
    End Sub Button1OnClick;

On clicking the button, the following information is displayed in the text editor: information about coordinate, fact index, by which formula is written, the number of formulas, which have coordinate, is specified.

See also:

IMDCalculationInstance