System.Copy

From RAD Studio API Documentation
Jump to: navigation, search

Delphi

function Copy(S: <string or dynamic array>; Index: Integer; Count: Integer): string;

Properties

Type Visibility Source Unit Parent
function public System.pas System System

Description

Returns a substring of a string or a segment of a dynamic array.

S is an expression of a string or dynamic-array type. Index and Count are integer-type expressions. Copy returns a substring or subarray containing Count characters or elements starting at S[Index]. The substring or subarray is a unique copy (that is, it does not share memory with S; if the elements of the array are pointers or objects, these are not copied as well.)

If Index is larger than the length of S, Copy returns an empty string or array.

If Count specifies more characters or array elements than are available, only the characters or elements from S[Index] to the end of S are returned.

Notes:
  • Copy uses one-based array indexing even in platforms where the strings are zero-based.
  • When S is a dynamic array, you can omit the Index and Count parameters and Copy copies the entire array.

See Also

Code Examples