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 modeling container includes the Var_1 variable that is set up for data loading by the formula.

Sub Main;

Var

MB: IMetabase;

MObj: IMetabaseObject;

Variable: IMsVariable;

LoadSetting: IMsVariableLoadSettings;

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(2000, 1, 1);

Period.IdentificationEndDate := DateTime.ComposeDay(2004, 1, 1);

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 first variable

For i := Matr.LowerBound(0) To Matr.UpperBound(0) Do

Mcoo.Item(0) := i;

Debug.Write(Matr.Item(Mcoo) + " ");

End For;

Debug.WriteLine("");

//Data calculation and loading

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(0) To Matr.UpperBound(0) Do

Mcoo.Item(0) := i;

Debug.Write(Matr.Item(Mcoo) + " ");

End For;

MObj.Save;

End Sub Main;

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