ChangeValueFlag(FlagFrom: Integer; FlagTo: Integer);
ChangeValueFlag(FlagFrom: integer; FlagTo: integer);
FlagFrom - flag of changed elements, for which it is necessary to assign new value.
FlagTo - new value of changed elements flag.
The ChangeValueFlag method changes the flag that is used to select changed values.
Use the IMatrix.ValueFlag property to determine flag value.
To execute the example, add links to the MathFin and Matrix system assemblies.
Sub UserProc;
Var
M: Matrix[2];
Mm: IMatrix;
Iter: IMatrixIterator;
Coord: IMatrixCoord;
x, y: Integer;
Begin
For x := 0 To 4 Do
For y := 0 To 4 Do
M[x, y] := Math.RandBetweenI(0, 9);
End For;
End For;
Mm := M As IMatrix;
Debug.WriteLine("Original matrix");
Iter := Mm.CreateIterator;
Iter.Move(IteratorDirection.First);
While Iter.Valid Do
Debug.WriteLine(Iter.Value + " " + Iter.ValueFlag.ToString);
Iter.Move(IteratorDirection.Next);
End While;
Mm.ValueFlag := 1;
Coord := Mm.CreateCoord;
Coord.Item(0) := 0;
Coord.Item(1) := 0;
Mm.Item(Coord) := 11;
Coord.Item(0) := 2;
Coord.Item(1) := 2;
Mm.Item(Coord) := 13;
Mm.ValueFlag := 2;
Coord.Item(0) := 1;
Coord.Item(1) := 1;
Mm.Item(Coord) := 12;
Coord.Item(0) := 3;
Coord.Item(1) := 3;
Mm.Item(Coord) := 14;
Debug.WriteLine("Before the flag is changed");
Iter.Move(IteratorDirection.First);
While Iter.Valid Do
Debug.WriteLine(Iter.Value + " " + Iter.ValueFlag.ToString);
Iter.Move(IteratorDirection.Next);
End While;
Mm.ChangeValueFlag(1, 10);
Debug.WriteLine("After the flag is changed");
Iter := Mm.CreateIterator;
Iter.Move(IteratorDirection.First);
While Iter.Valid Do
Debug.WriteLine(Iter.Value + " " + Iter.ValueFlag.ToString);
Iter.Move(IteratorDirection.Next);
End While;
End Sub UserProc;
After executing the example a matrix with random values is created. Values of four diagonal elements are updated in this matrix. Values are changed with different flag. After this, flag value of the elements, that were changed with matrix flag 1, changes to 10. Elements values and their corresponding flags are displayed in the development environment console.
To execute the example, add links to the MathFin, Matrix and ForeSystem system assemblies.
Imports Prognoz.Platform.Interop.ForeSystem;
Imports Prognoz.Platform.Interop.MathFin;
Imports Prognoz.Platform.Interop.Matrix;
…
Public Shared Sub Main(Params: StartParams);
Var
M: Array;
Mm: IMatrix;
Iter: IMatrixIterator;
Coord: IMatrixCoord;
Math: MathClass = New MathClass();
x, y: Integer;
Begin
For x := 0 To 4 Do
For y := 0 To 4 Do
M[x, y] := Math.RandBetweenI(0, 9);
End For;
End For;
Mm := M As IMatrix;
System.Diagnostics.Debug.WriteLine("Original matrix");
Iter := Mm.CreateIterator();
Iter.Move(IteratorDirection.itdFirst);
While Iter.Valid Do
System.Diagnostics.Debug.WriteLine(Iter.Value + " " + Iter.ValueFlag.ToString());
Iter.Move(IteratorDirection.itdNext);
End While;
Mm.ValueFlag := 1;
Coord := Mm.CreateCoord();
Coord.Item[0] := 0;
Coord.Item[1] := 0;
Mm.Item[Coord] := 11;
Coord.Item[0] := 2;
Coord.Item[1] := 2;
Mm.Item[Coord] := 13;
Mm.ValueFlag := 2;
Coord.Item[0] := 1;
Coord.Item[1] := 1;
Mm.Item[Coord] := 12;
Coord.Item[0] := 3;
Coord.Item[1] := 3;
Mm.Item[Coord] := 14;
System.Diagnostics.Debug.WriteLine("Before the flag is changed");
Iter.Move(IteratorDirection.itdFirst);
While Iter.Valid Do
System.Diagnostics.Debug.WriteLine(Iter.Value + " " + Iter.ValueFlag.ToString());
Iter.Move(IteratorDirection.itdNext);
End While;
Mm.ChangeValueFlag(1, 10);
System.Diagnostics.Debug.WriteLine("After the flag is changed");
Iter := Mm.CreateIterator();
Iter.Move(IteratorDirection.itdFirst);
While Iter.Valid Do
System.Diagnostics.Debug.WriteLine(Iter.Value + " " + Iter.ValueFlag.ToString());
Iter.Move(IteratorDirection.itdNext);
End While;
End Sub;
See also: