Copies bytes from a source to a destination.
procedure Move(const Source; var Dest; Count: Integer);
Move(const Source, Dest, int Count);
Move copies Count bytes from Source to Dest. No range checking is performed. Move compensates for overlaps between the source and destination blocks.
Whenever possible, use the global SizeOf function (Delphi) or the sizeof operator (C++) to determine the count.
Delphi Examples:
{ This example moves characters from a Char array into an integer. Displaying the integer as a hex, you can see that 'W' (0x57) is stored in the least significant byte of the integer. } var A: array[1..4] of Char; B: Integer; procedure DisplayAB; begin Form1.ListBox1.Items[0] := A[1]; Form1.ListBox1.Items[1] := A[2]; Form1.ListBox1.Items[2] := A[3]; Form1.ListBox1.Items[3] := A[4]; Form1.Edit1.Text := IntToHex(B, 1); end; procedure TForm1.Button1Click(Sender: TObject); begin Move(A, B, SizeOf(B)); { SizeOf = safety! } DisplayAB; end; procedure TForm1.FormCreate(Sender: TObject); var I : Integer; begin A[1] := 'W'; A[2] := 'H'; A[3] := 'A'; A[4] := 'T'; B := 5; DisplayAB; end;
Copyright(C) 2009 Embarcadero Technologies, Inc. All Rights Reserved.
|
What do you think about this topic? Send feedback!
|