Name

Move Procedure

Syntax

procedure Move(const Source; var Dest; Count: Integer);

Description

The Move procedure copies Count bytes from Source to Dest. Move is a real procedure.

Tips and Tricks

  • Source and Dest are not pointers, so pass the actual variables, or dereference pointers to dynamically allocated memory.

  • Move can handle overlapping memory correctly.

Example

// Insert an item into the middle of an array. Discard the
// value that is currently at A[High(A)].
procedure ArrayInsert(var A: array of Integer; Value, Index: Integer);
begin
  Assert((Low(A) <= Index) and (Index <= High(A));
  // First make room for the new value.
  Move(A[Index], A[Index+1], (High(A)-Index) * SizeOf(Integer));
  // Then save the value in the array.
  A[Index] := Value;
end;

See Also

FillChar Procedure

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.