This section describes the procedure of displaying variable values in the console window.
In the modelling example, after problem calculation results were unloaded to the Balance of Trade, billion USD variable by the Fact scenario. The module described below is used to view these results.
To run the module of viewing calculation results, the user needs to add links to the Ms, Metabase,Cubes,Dimensions,Matrix assemblies.
Sub Main;
Var
MB: IMetabase;
KMDesc: IMetabaseObjectDescriptor;
Problem: IMsProblem;
VarList: IVariableStubList;
VarStub: IVariableStub;
VarObj: IMetabaseObject;
CubeInst: ICubeInstance;
Des: ICubeInstanceDestination;
DimSS: IDimSelectionSet;
DimS: IDimSelection;
Elem: IDimElementArray;
Mat: IMatrix;
Coord: IMatrixCoord;
i: Integer;
Begin
MB := MetabaseClass.Active;
KMDesc := MB.ItemById("MODEL_SPACE");
Problem := mb.ItemByIdNamespace("PROBLEM_BALANCE", KMDesc.Key).Bind As IMsProblem;
// Get output variable
VarList := Problem.VariableStubs(MsVariableKind.Output);
VarStub := VarList.FindById("BALANCE");
// Get variable view in express analysis
VarObj := (VarStub As IMsVariable).Cube As IMetabaseObject;
CubeInst := VarObj.Open(Null) As ICubeInstance;
Des := CubeInst.Destinations.DefaultDestination;
DimSS := Des.CreateDimSelectionSet;
// Select data frequency: Annual
DimS := DimSS.Item(0);
Elem := DimS.Dimension.Levels.Item(0).Elements;
For Each i In Elem Do
DimS.SelectElement(i, False);
End For;
// Select the Fact scenario dictionary
DimSS.Item(1).SelectAll;
// Get matrix of variable data
Mat := Des.Execute(DimSS);
Coord := Mat.CreateCoord;
Coord.Item(1) := 0;
// Display matrix with data in the console window
Debug.WriteLine(Data of variable + VarStub.Name + :);
For Each i In Elem Do
Coord.Item(0) := i;
// Mat.Item(Coord) := Math.RandBetween(50, 100);
Debug.WriteLine(Mat.Item(Coord));
End For;
End Sub Main;
After executing the example results of problem calculation unloaded to the Balance of Trade, billion USD variable are displayed in the console window.
See also: