Child(Element: Integer; ChildIndex: Integer): Integer;
Element. Parent element index. 0, if it is root element.
ChildIndex. Child element index with relative to parent.
The Child property returns the number of child element relative to the entire tree.
Executing the example requires a model in the modeling container. The model contains input variables with additional dimensions.
Sub Main;
Var
MB: IMetabase;
Model: IMsModel;
TransVar: IMsFormulaTransformVariable;
SliceTree: IMsFormulaTransformSlicesTree;
i: Integer;
Begin
MB := MetabaseClass.Active;
Model := MB.ItemByIdNamespace("NEW_NONLINREG", MB.ItemById("KONT_MODEL").Key).Bind As IMsModel;
TransVar := Model.Transform.Inputs.Item(0);
SliceTree := TransVar.SlicesTree(TransVar);
For i := 0 To SliceTree.ChildrenCount(0) - 1 Do
Debug.WriteLine(SliceTree.Name(SliceTree.Child(0, i)));
If SliceTree.ChildrenCount(SliceTree.Child(0, i)) <> 0 Then
DebugChildren(SliceTree.Child(0, i), SliceTree, " ");
End If;
End For;
End Sub Main;
Sub DebugChildren(Element: Integer; SliceTree: IMsFormulaTransformSlicesTree; s: String);
Var
j: Integer;
Begin
For j := 0 To SliceTree.ChildrenCount(Element) - 1 Do
Debug.WriteLine(s + SliceTree.Name(SliceTree.Child(Element, j)));
If SliceTree.ChildrenCount(SliceTree.Child(Element, j)) <> 0 Then
DebugChildren(SliceTree.Child(Element, j), SliceTree, " ");
End If;
End For;
End Sub DebugChildren;
After executing the example, tree of the first input variable slices of the model is viewed recursively. Names of all tree elements are displayed in the console.
See also: