ChildrenCount(Element: Integer): Integer;
Element. Element index.
The ChildrenCount property returns the quantity of child elements, concerning an element, which number is passed by the Element parameter.
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: