IMsMetaModelVisualController.AddInputVariable

Syntax

AddInputVariable(Model: IMsModel;
                 EntryKey: Integer;
                 GraphMeta: String;
                 Var InterVariableKey: Integer;
                 Var InterModelKey: Integer;
                 [InterParentKey: Integer = -1]): Boolean;

Parameters

Model. Model.

EntryKey. Key of the variable, which is added to the model as an input one.

GraphMeta. Graphical context.

InterVariableKey. Key of a intermediate variable.

InterModelKey. The key of the transitional model of interpolation/collapse.

InterParentKey. Minor parent element key.

Description

The AddInputVariable method changes model input variable.

Comments

By default, input variable matches the output variable.

If input variable is successfully deleted, the method returns True, otherwise it returns False.

Example

Executing the example requires:

  1. Time series database with the TSDB identifier containing a time series with the 12 key.

  2. Modeling container with the MS identifier containing a modeling problem with the ADDINPUTVARIABLE identifier. Calculation chain of this problem must contain a model.

Add links to the Dimensions, Metabase, Ms system assemblies.

Sub UserProc;
Var
    mb: IMetabase;
    RubObj: IMetabaseObjectDescriptor;
    Problem: IMsProblem;
    Meta: IMsMetaModel;
    MetaVisual: IMsMetaModelVisualController;
    ChainEn: IMsCalculationChainEntries;
    i: Integer;
    Model: IMsModel;
    VarEx, InpResult: Boolean;
    VarInp: IMsCalculationChainVariable;
    InVarKey, InModelKey: Integer;
Begin
    mb := MetabaseClass.Active;
    // Get time series database
    RubObj := mb.ItemById("TSDB");
    // Get modeling problem and its metamodel
    Problem := mb.ItemByIdNamespace("ADDINPUTVARIABLE", mb.ItemById("MS").Key).Edit As IMsProblem;
    Meta := Problem.MetaModel;
    // Get model from calculation chain
    ChainEn := Meta.CalculationChain;
    For i := 0 To ChainEn.Count - 1 Do
        If ChainEn.Item(i).Type = MsCalculationChainEntryType.Model Then
            Model := (ChainEn.Item(i) As IMsCalculationChainModel).Model;
        End If;
    End For;
    MetaVisual := Meta.VisualController;
    // Get the key of the input variable
    VarInp := MetaVisual.GetVariableByFactor(RubObj.Key, 12"", VarEx);
    // Set input variable
    InpResult := MetaVisual.AddInputVariable(Model, VarInp.Key, "", InVarKey, InModelKey, -1);
    // Output result to console window
    Debug.WriteLine("Input variable is successfully added: " + InpResult.ToString);
    // Save modeling problem
    (Problem As IMetabaseObject).Save;
End Sub UserProc;

After executing the example the input variable is changed for the first model in the calculation chain of the ADDINPUTVARIABLE problem. The variable created on the time series from time series database is used.

See also:

IMsMetaModelVisualController