Slice

Return part of an array

Declaration

Source position: system.fpd line 91

  function Slice(const A: ArrayType; ACount: Integer) : ArrayType2;

Description

Slice returns the first ACount elements from the array A. It returns an array with the same element type as A, but this array is not assignment compatible to any other array, and can therefor only be used in open array arguments to functions.

See also

Name Description
Length Returns length of a string or array.
SetLength Set length of a string or dynamic array.

Example

Program Example113;
{ Program to demonstrate the Slice function. }
procedure ShowArray(const A: array of Integer);
var
  I: Integer;
begin
  for I := Low(A) to High(A) do
    WriteLn(I, ' : ', A[I]);
end;
begin
  ShowArray(Slice([1,2,3,4],2));
end.