Name
Copy Function
Syntax
function Copy(Source: string; StartingIndex, Count: Integer): string; function Copy(Source: array; StartingIndex, Count: Integer): array;
Description
The Copy
function creates a copy of part of a
string or dynamic array. The result is a new string or dynamic array.
The new string or array starts with the element at
StartingIndex
in Source
. The
new string or array contains up to Count
elements.
If Count
exceeds the number of items remaining in
the source string or array, the elements from
StartingIndex
to the end of the string or array
are copied.
Copy
is not a real function.
Tips and Tricks
If
StartingIndex
is less than zero or past the end ofSource
, the result is an empty string or array.The length of the new string or array is
Count
unless theSource
has fewer thanCount
elements to copy, in which caseCopy
copies all the elements up to the end of the string or array.The first index of a string is 1. The first index of a dynamic array is 0.
A convenient way to copy all the elements of
Source
from the starting index is to useMaxInt
as theCount
.
See Also
Delete Function, High Function, Insert Procedure, Length Function, Low Function, SetLength Procedure, SetString Procedure, Slice Function |
Get Delphi in a Nutshell now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.