IMsScenarioTreeEntries.RemoveByKeyEx

Fore Syntax

RemoveByKeyEx(EntryKey: Integer; Recursive: Boolean): Boolean;

Fore.NET Syntax

RemoveByKeyEx(EntryKey: uinteger; Recursive: boolean): boolean;

Parameters

EntryKey. Key of the element that must be removed.

Recursive. It determines whether to perform recursive removal of child elements. Available values:

Description

The RemoveByKeyEx method removes the element from the scenario tree with ability of recursive removal of child elements.

Comments

If the removal is successful, the method returns True, otherwise it returns False.

Fore Example

Executing the example requires that the repository contains a modeling container with the MS identifier. This modeling container should include scenarios.

Add links to the Metabase, Ms system assemblies.

Sub UserProc;
Var
    MB: IMetabase;
    MsObj: IMetabaseObject;
    ModelSpace: IMsModelSpace;
    Tree: IMsScenarioTreeEntries;
    Element: IMsScenarioTreeEntry;
    res: Boolean;
Begin
    // Get modeling container
    MB := MetabaseClass.Active;
    MsObj := MB.ItemById("MS").Edit;
    ModelSpace := MsObj As IMsModelSpace;
    // Get scenario tree
    Tree := ModelSpace.ScenarioTree;
    // Get the first element of the tree
    Element := Tree.Item(0);
    // Perform recursive removal
    res := Tree.RemoveByKeyEx(Element.Key, True);
    // Display removal results in the console window
    Debug.WriteLine("Removal is successful: " + res.ToString);
    // Save changes
    MsObj.Save;
End Sub UserProc;

After execution of the example the recursive deletion of the first scenario tree will be performed. Removal results are displayed in the console window.

Fore.NET Example

The requirements and result of the Fore.NET example execution match with those in the Fore example.

Imports Prognoz.Platform.Interop.Ms;

Public Shared Sub Main(Params: StartParams);
Var
    MB: IMetabase;
    MsObj: IMetabaseObject;
    ModelSpace: IMsModelSpace;
    Tree: IMsScenarioTreeEntries;
    Element: IMsScenarioTreeEntry;
    res: Boolean;
Begin
    // Get modeling container
    MB := Params.Metabase;
    MsObj := MB.ItemById["MS"].Edit();
    ModelSpace := MsObj As IMsModelSpace;
    // Get scenario tree
    Tree := ModelSpace.ScenarioTree;
    // Get the first element of the tree
    Element := Tree.Item[0];
    // Perform recursive removal
    res := Tree.RemoveByKeyEx(Element.Key, True);
    // Display removal results in the console window
    System.Diagnostics.Debug.WriteLine("Removal is successful: " + res.ToString());
    // Save changes
    MsObj.Save();
End Sub;

See also:

IMsScenarioTreeEntries