IMatrixIterator.SetValueFlagEx

Syntax

SetValueFlagEx(lAnd: Integer; lOr: Integer);

Parameters

lAnd - value, with which the bitwise operation And is performed.

lOr - value, with which the bitwise operation Or is performed.

Description

The SetValueFlagEx method performs bitwise operations with element flag value. First, the bitwise operation And is performed with the current element flag and value of the lAnd parameter, then the bitwise operation Or is performed with value of the lOr parameter and the value obtained after the first operation.

Example

ValueFlag lAnd lOr
3 (11) 2(10) 5(101)

When the SetValueFlagEx method is called, first operation (2 And 3)=(11 And 10)=2(10) is calculated for the changed element. Then (2 Or 5)=(10 Or 101)=7(111) is calculated. The final flag value is set to 7 for this element.

Example

Sub Main;

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;

Mm.ValueFlag := 3;

Coord := Mm.CreateCoord;

Coord.Item(0) := Math.RandBetweenI(0, 4);

Coord.Item(1) := Math.RandBetweenI(0, 4);

Iter := Mm.CreateIterator;

Iter.PutCoord(Coord);

Iter.Value := 10;

Iter.Move(IteratorDirection.First);

While Iter.Valid Do

Iter.SetValueFlagEx(2, 5);

Debug.WriteLine(Iter.Value + " " + Iter.ValueFlag.ToString);

Iter.Move(IteratorDirection.Next);

End While;

End Sub Main;

After executing the example a matrix with random values is created. A value of the flag that is used to select changed values is set for the matrix. The value is changed for a random element. After that on the base of a matrix an iterator will be obtained and bitwise operations with specified values are performed for a flag of each element. The flag 7 is set for all changed elements, for unchanged - 5.

See also:

IMatrixIterator