1. Home
  2. Computing & Technology
  3. Delphi Programming

Delphi Programming RTL Reference|By Category|Alphabetically|By Unit
 

Copy

unit
System
category
string handling routines

declaration
function Copy(S; Index, Count: Integer): string;
function Copy(S; Index, Count: Integer): array;

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 string containing a specified number of characters from a string or sub array containing Count elements starting at S[Index].

If Index is greater than the length of S, Copy returns a zero-length string ("") or an empty 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.

To determine the number of characters in string, use the Length function. A convenient way to copy all the elements of S from the starting Index is to use MaxInt as Count.

example
var s : string;

s:='DELPHI';
s := Copy(s,2,3);
//s='ELP';

in real code
String Types in Delphi
Understanding and managing string data types in Delphi's Object Pascal. Learn about differences between Short, Long, Wide and null-terminated strings.
Arrays in Object Pascal
Understanding and using array data types in Delphi.
Traveling Label
Spice up your user interface with a marquee style text. Use marquee style text to display scrolling text that you want to catch your Delphi program users' attention.

see also
Delete, Insert, Length, Concat, Pos, Slice,
Explore Delphi Programming
About.com Special Features

Stay connected and entertained with reviews on tips on the latest HDTVs, cellphones and more. More >

Easy ways to connect two computers for networking purposes. More >

  1. Home
  2. Computing & Technology
  3. Delphi Programming

©2009 About.com, a part of The New York Times Company.

All rights reserved.