IMatrixEx.CreateWritableProxyO

Syntax

CreateWritableProxyO(Options: Integer): IMatrix;

Parameters

Options. Parameters of creating a proxy object of data matrix.

Description

The CreateWritableProxyO method creates a proxy object of data matrix.

Comments

Use the 0 value in the Options parameter. Created proxy object provides separate work with initial and modified matrix data. To control data, cast the CreateWritableProxyO method result to the IMatrixWritableProxy interface.

Example

Executing the example requires that the repository contains a cube with the CUBE identifier.

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

Sub UserProc;
Var
    MB: IMetabase;
    CubeInst: ICubeInstance;
    DefDest: ICubeInstanceDestination;
    SelSet: IDimSelectionSet;
    i: integer;
    DestExec: ICubeInstanceDestinationExecutor;
    Proxy: IMatrix;
    Wp: IMatrixWritableProxy;
    Iter: IMatrixIterator;
    Mc: IMatrixCoord;
Begin
    MB := MetabaseClass.Active;
    CubeInst := MB.ItemById(
"CUBE").Open(NullAs ICubeInstance;
    DefDest := CubeInst.Destinations.DefaultDestination;
    SelSet := DefDest.CreateDimSelectionSet;
    
For i := 0 To SelSet.Count - 1 Do
        SelSet.Item(i).SelectAll;
    
End For;
    DestExec := DefDest.CreateExecutorO(CubeInstanceDestinationExecutorOptions.MatrixProxy);
    DestExec.PrepareExecute(SelSet);
    DestExec.PerformExecute(
False);
    Proxy := (DestExec.Matrix 
As IMatrixEx).CreateWritableProxyO(0);
    Wp := Proxy 
As IMatrixWritableProxy;
    Debug.WriteLine(
"---------------Initial values in matrix and proxy matrix-------------------");
        ShowMatrix(
"Proxy", Proxy);
        ShowMatrix(
"BaseMatrix", Wp.BaseMatrix);
        ShowMatrix(
"ChangeMatrix", Wp.ChangeMatrix);
    Debug.WriteLine(
"---------------Add a new value-----------------------------------------");
    Mc := Proxy.CreateCoord;
    Iter := Proxy.CreateIterator;
    Iter.Move(IteratorDirection.First);
    Iter.PutCurrentPos(Mc);
    
For i := 0 To Mc.Count - 1 Do
        Mc.Item(i) := Mc.Item(i) + 
1
    
End For;
    
//Check whether coordinate exists
    Iter.Goto(Mc);
    
If Iter.Valid Then
        Debug.WriteLine(
"Coordinate already exists.");
    
Else
        Debug.WriteLine(
"Coordinate does not exist.");
    
End If;
    
//Move to coordinate and set value. If coordinate does not exist, then matrix will be expanded
    Iter.PutCoord(Mc);
    Iter.Value := 
100500;
    Debug.WriteLine(
"New value = " + Iter.Value);
    Debug.WriteLine(
"---------------Changed/added values------------------------------------");
        ShowMatrix(
"Proxy", Proxy);
        ShowMatrix(
"BaseMatrix", Wp.BaseMatrix);
        ShowMatrix(
"ChangeMatrix", Wp.ChangeMatrix);
    Debug.WriteLine(
"---------------after ApplyChanges-------------------------------------------------");
    Wp.ApplyChanges;
        ShowMatrix(
"Proxy", Proxy);
        ShowMatrix(
"BaseMatrix", Wp.BaseMatrix);
        ShowMatrix(
"ChangeMatrix", Wp.ChangeMatrix);
    Debug.WriteLine(
"---------------Repeated value changing by coordinate-------------------------");
    Iter.PutCoord(Mc);
    Iter.Value := -Iter.Value;
    Debug.WriteLine(
"New value = " + Iter.Value);
    Debug.WriteLine(
"---------------Changed/added values------------------------------------");
        ShowMatrix(
"Proxy", Proxy);
        ShowMatrix(
"BaseMatrix", Wp.BaseMatrix);
        ShowMatrix(
"ChangeMatrix", Wp.ChangeMatrix);
    Debug.WriteLine(
"---------------after RevertChanges------------------------------------------------");
    Wp.RevertChanges;
        ShowMatrix(
"Proxy", Proxy);
        ShowMatrix(
"BaseMatrix", Wp.BaseMatrix);
        ShowMatrix(
"ChangeMatrix", Wp.ChangeMatrix);
End Sub UserProc;

Sub ShowMatrix(MatrixName: String; Matr: IMatrix);
Var
    Iter: IMatrixIterator;
Begin
    Debug.Write(MatrixName + 
" : ");
    
If Matr.Count <> 0 Then
        Iter := Matr.CreateIterator;
        Iter.Move(IteratorDirection.First);
        
While Iter.Valid Do
            Debug.Write(Iter.Value + 
" ");
            Iter.Move(IteratorDirection.Next);
        
End While;
        Debug.WriteLine(
"");
    
Else
        Debug.WriteLine(
"Empty");
    
End If;
End Sub ShowMatrix;

On executing the example, a new value is added to matrix and then it is changed. The development environment console displays data of initial matrix, proxy object matrix and matrix where changed values of proxy object during work process are stored.

See also:

IMatrixEx