Unit 'System' Package
[Overview][Constants][Types][Classes][Procedures and functions][Variables][Index] [#rtl]

Slice

Return part of an array.

Declaration

Source position: system.fpd line 92

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

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
  or := Low(A) to High(A) do
    WriteLn(I, ' : ', A[I]);
end;

begin
  ShowArray(Slice([1,2,3,4],2));
end.

Documentation generated on: Oct 02 2024