IMsFormulaTransformVariables.Add

Syntax

Add(Value: IVariableStub): IMsFormulaTransformVariable;

Parameters

Value. The variable of the modeling container that must be added to the model.

Description

The Add method adds a variable to the collection.

Example

Executing the example requires a modeling container with the MS_COMM identifier, that contains determinate equation model with the OBJ_MODEL identifier and a variable with the OBJ_VAR identifier. Add links to the Metabase, Ms, Cubes system assemblies.

Sub UserProc;
Var
    mb: IMetabase;
    MsDescr: IMetabaseObjectDescriptor;
    Model: IMsModel;
    Transform: IMsFormulaTransform;
    InputVars: IMsFormulaTransformVariables;
    Varable: IVariableStub;
    TransformVar: IMsFormulaTransformVariable;
    Slice: IMsFormulaTransformSlice;
    Term: IMsFormulaTerm;
    Formula: IMsFormula;
    DetermTrans: IMsDeterministicTransform;
    Expr: IExpression;
Begin
    mb := MetabaseClass.Active;
    MsDescr := mb.ItemById("MS_COMM");
    Model := mb.ItemByIdNamespace("OBJ_MODEL", MsDescr.Key).Edit As IMsModel;
    Transform := Model.Transform;
// Get input variables collection
    InputVars := Transform.Inputs;
// Clearing output variables collection, if elements are present there
    If  Transform.Series.Count > 0 Then
        InputVars.Clear;
    End If;
// Get calculation method parameters
    Formula := Transform.FormulaItem(0);
    DetermTrans := Formula.Method As IMsDeterministicTransform;
// Adding one variable to the model
    Varable := mb.ItemByIdNamespace("OBJ_VAR", MsDescr.Key).Bind As IVariableStub;
    TransformVar := InputVars.Add(Varable);
    Slice := TransformVar.Slices.Add(Null);
    Term := DetermTrans.Operands.Add(Slice);
// Setting expression with the added variable
    Expr := DetermTrans.Expression;
    Expr.AsString := Term.TermToInnerText + " + 9";
// Saving model
    (Model As IMetabaseObject).Save;
End Sub UserProc;

After executing the example the OBJ_VAR variable is added to the OBJ_MODEL model. This variable is a part of the expression that is used for the model calculation.

See also:

IMsFormulaTransformVariables