DelphiBasics
Move
Procedure
Copy bytes of data from a source to a destination System unit
 procedure Move(const SourcePointer; var DestinationPointer; CopyCount Integer);
Description
The Move procedure is a badly named method of copying a section of memory from one place to another.
 
CopyCount bytes are copied from storage referenced by SourcePointer and written to DestinationPointer
 
It can be used to take a copy of a substring from one string and overlay it on top of part of another string.
 
If copying from the current string to another part of the same string, then Copy works intelligently, preserving data where appropriate.
Notes
The original data is always preserved, unless moving fronm and to the current string - so Move is not very informative.

There is no checking on the referenced storage areas - be careful about all direct storage operations such as this.
Related commands
AnsiReplaceStrReplaces a part of one string with another
ConcatConcatenates one or more strings into one string
CopyCreate a copy of part of a string or an array
DeleteDelete a section of characters from a string
InsertInsert a string into another string
StringOfCharCreates a string with one character repeated many times
StringReplaceReplace one or more substrings found within a string
StuffStringReplaces a part of one string with another
WrapTextAdd line feeds into a string to simulate word wrap
 Download this web site as a Windows program.




 
Example code : Copying a part of one string into the middle of another
var
  source, dest : string;
begin
  // Set up our starting string
  source := '123456789';
  dest   := '---------';

  // Copy a substring from source into the middle of dest
  Move(source[5], dest[3], 4);

  // Show the source and destination strings
  ShowMessage('Source = '+source);
  ShowMessage('Dest   = '+dest);
end;
Show full unit code
  Source = 123456789
  Dest = --5678---
 
Delphi Programming © Neil Moffatt . All rights reserved.  |  Home Page