Wikia

Delphi Programming

Copy

Talk0
2,909pages on
this wiki

Copy FunctionEdit

Unit System

DescriptionEdit

There are 2 different copy functions.

Definition (Delphi 6):

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

Strings: Copy function is used to copy a substring from source String(S).
The result is a substring which starts at the given Index and Count is length of the substring.

Arrays: Copy function is used to copy a subarray from the source array(S).
The result is a subarray which starts at the given Index and Count is number of elements to copy from the source array.

Technical CommentsEdit

The Copy function structure are:: Copy( String,Index,Count );
The Copy function contents are:: Copy( String,Integer,Integer );

  1. Copy: Calls the function
  2. String: Text content passed to be copyed
  3. Index: Start position by character where the function must to start count the copy function
  4. Count: Number of characters to be copyed within the function as the result.

More complicated combinations of code can work better any possible results for your projects.

ExamplesEdit

Examples must have on the form one or more TEdit and TButton components with its default names.

  • Edit1 must have a text set for 'Testing the Copy function';
  • for test the examples copy and paste the codes on the OnClick event for Button1.


Using the Copy function.Edit



This function will copy part of a text from Edit1
and show the result in a message function.


ShowMessage( Copy( Edit1.text, 1, 7 );
//Show in result the word "Testing"

ShowMessage( Copy( Edit1.text, 18, 8 );
//Show in result the word "function"

No aditional information.


See AlsoEdit

User Comments/TipsEdit

WDHellS

Advertisement | Your ad here

Around Wikia's network

Random Wiki