FindElementEntries(ElementKey: IMDCalculationFormulaElementKey): IMDCalculationFormulasIterator;
FindElementEntries(ElementKey: Prognoz.Platform.Interop.Cubes.IMDCalculationFormulaElementKey): Prognoz.Platform.Interop.Cubes.IMDCalculationFormulasIterator;
ElementKey. Key of the element, which is used to search for element occurrences in formulas.
The FindElementEntries method searches for element occurrences in formulas.
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.
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(Null) As 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.
The requirements and result of the Fore.NET example execution match with those in the Fore example.
Private Sub button1_Click(sender: System.Object; e: System.EventArgs);
Var
MB: IMetabase;
MDInst: IMDCalculationInstance;
Source: IMDCalculationSourceInstance;
Slices: IMDCalculationSlicesInstance;
Slice: IMDCalculationSliceInstance;
Coord: IMatrixCoord;
SourceElKey: IMDCalculationFormulaElementKey;
Iterator: IMDCalculationFormulasIterator;
s: List<string>;
i, j: Integer;
Begin
MB := Self.Metabase;
MDInst := MB.ItemById["OBJMD"].Open(Null) As 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;
s.Add(The " + Slice.Name + " contains selected element " + Slice.Dimension.Elements.Name[Coord.Item[i] As uinteger]);
End For;
SourceElKey := Source.CoordToKey(Coord, Null);
SourceElKey.FactIndex := 0;
Iterator := MDInst.FindElementEntries(SourceElKey);
j := 0;
While Not Iterator.Eof() Do
j := j + 1;
s.Add("fact: " + Iterator.Key().FactIndex.ToString());
Iterator.Next();
End While;
s.Add(The number of entries by coordinate: " + j.ToString());
TextBox1.Lines := s.ToArray();
End Sub;
See also: