[Overview][Constants][Types][Classes][Procedures and functions][Variables][Index] | Reference for unit 'System' (#rtl)

# Slice

Return part of an array

## Declaration

Source position: system.fpd line 74

`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.

## 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.

Documentation generated on: Feb 26 2014