Professional Documents
Culture Documents
Command Copy - Delphi
Command Copy - Delphi
Description
The copy function has 2 forms. In the first, it creates a new string from part of an existing string.
In the second, it creates a new array from part of an existing array.
1.String copy
Up to Count characters are copied from the StartChar of the Source string to the returned string.
Less than Count characters if the end of the Source string is encountered before Count characters
have been copied.
2.Array copy
Up to Count elements are copied from the StartIndex of the Source array to the returned array.
Less than Count elements if the end of the Source array is encountered before Count elements
have been copied
var
Source, Target : string;
begin
Source := '12345678';
Target := copy(Source, 3, 4);
ShowMessage('Target : '+Target);
end;
Show full unit code
Target : 3456
Example code : Array copy
var
i : Integer;
Source, Target : array of Integer;
begin
SetLength(Source, 8);
Target[0] : 4
Target[1] : 5
Target[2] : 6
Target[3] : 7