Array.Operation

Syntax

Operation(OperationType: ArrayOperationType, Value: Variant);

Parameters

OperationType. Type of arithmetic operation.

Value. Value that will be used on executing an operation with array elements.

Description

The Operation method executes arithmetic operation with array elements with the specified value.

Comments

The method is used to work with the following data types: Integer, Decimal, Float.

Example

To execute the example, add a link to the MathFin system assembly.

Sub UserProc;
Var
    Matr: Array Of Double;
    i, j: Integer;
Begin
    // Create a two-dimensional array
    Matr := New Double[33];
    Matr[00] := 4; Matr[01] := 9; Matr[02] := 3;
    Matr[10] := 2; Matr[11] := 15; Matr[12] := 7;
    Matr[20] := 8; Matr[21] := 5; Matr[22] := 13;
    Debug.WriteLine("Array before operation execution:");
    // Display the created array in the console
    For i := 0 To Matr.GetUpperBound(1Do
        For j := 0 To Matr.GetUpperBound(2Do
            Debug.Write(Matr[i, j].ToString + " ");
        End For;
        Debug.WriteLine("");
    End For;
    // Execute arithmetic operation with array elements
    Matr.Operation(ArrayOperationType.Minus, 2);
    // Display operation result in the console
    Debug.WriteLine("Array after operation execution:");
    For i := 0 To Matr.GetUpperBound(1Do
        For j := 0 To Matr.GetUpperBound(2Do
            Debug.Write(Matr[i, j].ToString + " ");
        End For;
        Debug.WriteLine("");
    End For;
End Sub UserProc;

After executing the example the console will display the array before and after operation execution. After executing the operation, values of array elements are decreased by 2:

The array before operation execution:

4 9 3

2 15 7

8 5 13

The array after operation execution:

2 7 1

0 13 5

6 3 11

See also:

Array