IMsVariableLoadSettings.CreateCalculation

Syntax

CreateCalculation: IMsMethodCalculation;

Description

The CreateCalculation method creates an object that contains settings used on calculating variable's values.

Example

Executing the example requires that the repository contains a modeling container with the KONT_MODEL identifier. The container includes a modeling variable with the VAR_1 identifier that is set up to load data using a formula.

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

Sub UserProc;
Var
    MB: IMetabase;
    MObj: IMetabaseObject;
    Variable: IMsVariable;
    LoadSetting: IMsVariableLoadSetting;
    MethodCalculation: IMsMethodCalculation;
    Period: IMsModelPeriod;
    DimFix: IMsProblemDimensionFix;
    DimSS: IDimSelectionSet;
    DimS: IDimSelection;
    MethodCacl: IMsMethodCalculation;
    Matr: IMatrix;
    Mcoo: IMatrixCoord;
    i: Integer;
Begin
    MB := MetabaseClass.Active;
    MObj := MB.ItemByIdNamespace("VAR_1", MB.ItemById("KONT_MODEL").Key).Edit;
    Variable := MObj As IMsVariable;
    LoadSetting := Variable.CreateLoadSettings;
    Period := LoadSetting.Period;
    Period.IdentificationStartDate := DateTime.ComposeDay(200011);
    Period.IdentificationEndDate := DateTime.ComposeDay(200411);
    LoadSetting.ScenarioIncluded(-1) := True;
    DimFix := LoadSetting.DimensionFix;
    DimSS := DimFix.Selection;
    For Each DimS In DimSS Do
        DimS.SelectAll;
    End For;
    MethodCacl := LoadSetting.CreateCalculation;
    Matr := MethodCacl.Variable(Variable.Transform.Inputs.Item(0).VariableStub);
    Mcoo := Matr.CreateCoord;
    Mcoo.Item(1) := 0;
    //Data of the first variable
    For i := Matr.LowerBound(0To Matr.UpperBound(0Do
        Mcoo.Item(0) := i;
        Debug.Write(Matr.Item(Mcoo) + " ");
    End For;
    Debug.WriteLine("");
    //Calculate and load data
    Variable.Execute(LoadSetting);
    Debug.WriteLine("Calculated data");
    Matr := MethodCacl.Variable(Variable.Transform.Outputs.Item(0).VariableStub);
    Mcoo := Matr.CreateCoord;
    Mcoo.Item(1) := 0;
    For i := Matr.LowerBound(0To Matr.UpperBound(0Do
        Mcoo.Item(0) := i;
        Debug.Write(Matr.Item(Mcoo) + " ");
    End For;
    MObj.Save;
End Sub UserProc;

After executing the example data is loaded to the variable. The data of the first variable that is used in the formula and calculated by data formula is displayed in the development environment console.

See also:

IMsVariableLoadSettings