HomeDelphiDelphi Error – E2193 Slice standard function only allowed as open array argument

Delphi Error – E2193 Slice standard function only allowed as open array argument

Delphi Compiler Error

E2193 Slice standard function only allowed as open array argument

Reason for the Error & Solution

An attempt has been made to pass an array slice to a fixed size array. Array slices can only be sent to open array parameters. none

program Produce;

  type
    IntegerArray = array [1..10] OF Integer;

  var
    SliceMe : array [1..200] OF Integer;

  procedure TakesArray(x : IntegerArray);
  begin
  end;

begin TakesArray(SLICE(SliceMe, 5));
end.

In the above example, the error is produced because TakesArray expects a fixed size array.

program Solve;

  type
    IntegerArray = array [1..10] OF Integer;

  var
    SliceMe : array [1..200] OF Integer;

  procedure TakesArray(x : array of Integer);
  begin
  end;

begin TakesArray(SLICE(SliceMe, 5));
end.

In the above example, the error is not produced because TakesArray takes an open array as the parameter.

Share:

Leave A Reply

Your email address will not be published. Required fields are marked *

You May Also Like

Delphi Compiler Error X2421 Imported identifier ‘%s’ conflicts with ‘%s’ in ‘%s’ Reason for the Error & Solution This occurs...
Delphi Compiler Error X2367 Case of property accessor method %s.%s should be %s.%s Reason for the Error & Solution No...
Delphi Compiler Error X2269 Overriding virtual method ‘%s.%s’ has lower visibility (%s) than base class ‘%s’ (%s) Reason for the...