Author: Christer Johansson
You have an array and you want to copy the value you have in it to another array.
Answer:
I just use a button to se if it compile and if I get an Error when I click it.
There ar other ways, like copy an array in a for loop, but then you have to know
how big it is. If you handle different arrays in an application and need to copy
them into one, this is the way. As you can se, it works with just one index of the
array too.
1 unit Unit1;
2
3 interface
4
5 uses
6 Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
7 StdCtrls;
8
9 type
10 TForm1 = class(TForm)
11 Label1: TLabel;
12 Button1: TButton;
13 procedure Button1Click(Sender: TObject);
14 private
15 Array1: array[0..40] of Integer;
16 Array2: array[0..100] of Integer;
17 public
18 { Public declarations }
19 end;
20
21 var
22 Form1: TForm1;
23
24 implementation
25
26 {$R *.DFM}
27
28 procedure TForm1.Button1Click(Sender: TObject);
29 begin
30 Move(Array1, Array2, SizeOf(Array1)); {Moves/Copy the Array1 to Array2.}
31 end;
32
33 end.
|