Got something weird here - weird because I probably don't understand it properly but it caused me a bit of delay... Simplified, I had a global array of records, during my procedure I would do something like this

PRec := MyArrayofPRec[0];
PRec.name := 'Hi';

Now for some reason I was expecting MyArrayOfPRec[0].name to be now 'Hi' as well, but it's not.

Here is an example that I whipped up just now which lead me to expect this.

type
 TMyRec = Record
   name : string;
 end;


var
 Form1: TForm1;
 TTH : TMyRec;

procedure TForm1.FormCreate(Sender: TObject);
begin
 TTH.name := 'BoB';
end;

procedure TForm1.Button1Click(Sender: TObject);
var
 t : TMemo;
 b : TMyRec;
begin
 t := Memo1;
 t.lines.add('hi');

 b := TTH;
 b.name := 'Smile';
 t.lines.add(TTH.name);
end;

Now in this example when it's ran and button 1 is clicked - Hi is added to the Memo1 and Bob is added. So why can I assign Memo1 to T and all actions done to T are done to Memo1, but the same isn't with the Record.
Is it because Record isn't from TObject?
I guess it's like
var
   a,b : integer;
begin
   a := 1;
   b := a;
   b := 10; //a still = 1 which is what I would expect
end;

so is it because TMemo is an Object and the record and a,b above are just variables?

O.o
Thanks



_______________________________________________
NZ Borland Developers Group - Delphi mailing list
Post: delphi@delphi.org.nz
Admin: http://delphi.org.nz/mailman/listinfo/delphi
Unsubscribe: send an email to [EMAIL PROTECTED] with Subject: unsubscribe

Reply via email to