IMatrix.ValueChangeCallback

Syntax

ValueChangeCallback: IValueChangeCallback;

ValueChangeCallback: Prognoz.Platform.Interop.Matrix.IValueChangeCallback;

Description

The ValueChangeCallback property determines an object that will be used to monitor value changes in matrix.

Comments

AS value, specify an instance of the custom class that implements methods of the IValueChangeCallback interface.

Example

Executing the example requires a standard cube with the STD_CUBE identifier. The cube structure contains dimensions with the FACTS, COUNTRY and CALENDAR identifiers.

Add links to the Cubes, Dimensions, Matrix and Metabase system assemblies.

Sub UserProc;
Var
    MB: IMetabase;
    Cube: ICubeInstance;
    Dest: ICubeInstanceDestination;
    Exec: ICubeInstanceDestinationExecutor;
    Sels: IDimSelectionSet;
    Matrix: IMatrix;
    Coord: IMatrixCoord;
Begin
    
//Open cube
    MB := MetabaseClass.Active;
    Cube := MB.ItemById(
"STD_CUBE").Open(NullAs ICubeInstance;
    Dest := Cube.Destinations.DefaultDestination;
    
//Create selection
    Sels := Dest.CreateDimSelectionSet;
    Sels.FindById(
"FACTS").SelectAll;
    Sels.FindById(
"COUNTRY").SelectElement(0False);
    Sels.FindById(
"CALENDAR").SelectElement(0False);
    
//Run
    Exec := Dest.CreateExecutor;
    Exec.PrepareExecute(Sels);
    Exec.PerformExecute;
    
//Get matrix with values
    Matrix := Exec.Matrix;
    
//Set dimension handler
    Matrix.ValueChangeCallback := New ValueChangeCallback.Create;
    
//Change matrix element value, the OnValueChanged event will be generated
    Coord := Matrix.CreateCoord;
    Coord.Item(
0) := 0;
    Coord.Item(
1) := 0;
    Coord.Item(
1) := 0;
    Matrix.Item(Coord) := 
500;
End Sub UserProc;

Class ValueChangeCallback: Object, IValueChangeCallback
    
Sub OnValueChanged(Value: IMatrixCoord);
    
Var
        M: IMatrix;
    
Begin
        M := Value.Matrix;
        Debug.WriteLine(
"New value: " + M.Item(Value));
    
End Sub OnValueChanged;
End Class ValueChangeCallback;

Imports Prognoz.Platform.Interop.Cubes;
Imports Prognoz.Platform.Interop.Dimensions;
Imports Prognoz.Platform.Interop.Matrix;
Imports Prognoz.Platform.Interop.Metabase;

Public Shared Sub Main(Params: StartParams);
Var
    MB: IMetabase;
    Cube: ICubeInstance;
    Dest: ICubeInstanceDestination;
    Exec: ICubeInstanceDestinationExecutor;
    Sels: IDimSelectionSet;
    Matrix: IMatrix;
    Coord: IMatrixCoord;
Begin
    
//Open cube
    MB := Params.Metabase;
    Cube := MB.ItemById[
"STD_CUBE"].Open(NullAs ICubeInstance;
    Dest := Cube.Destinations.DefaultDestination;
    
//Create selection
    Sels := Dest.CreateDimSelectionSet();
    Sels.FindById(
"FACTS").SelectAll();
    Sels.FindById(
"COUNTRY").SelectElement(0False);
    Sels.FindById(
"CALENDAR").SelectElement(0False);
    
//Run
    Exec := Dest.CreateExecutor();
    Exec.PrepareExecute(Sels);
    Exec.PerformExecute(
False);
    
//Get matrix with values
    Matrix := Exec.Matrix;
    
//Set dimension handler
    Matrix.ValueChangeCallback := New ValueChangeCallback();
    
//Change matrix element value, the OnValueChanged event will be generated
    Coord := Matrix.CreateCoord();
    Coord.Item[
0] := 0;
    Coord.Item[
1] := 0;
    Coord.Item[
1] := 0;
    Matrix.Item[Coord] := 
500;
End Sub;

Class ValueChangeCallback: Object, IValueChangeCallback
    
Public Sub OnValueChanged(Value: IMatrixCoord);
    
Var
        M: IMatrix;
    
Begin
        M := Value.Matrix;
        System.Diagnostics.Debug.WriteLine(
"New value: " + M.Item[Value]);
    
End Sub OnValueChanged;
End Class ValueChangeCallback;

On executing the example, the cube value matrix will be obtained. The object used to monitor value changes will be set for matrix. After that the value will be changed by the specified coordinate.

See also:

IMatrix