<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">2013/9/23 Michael Van Canneyt <span dir="ltr"><<a href="mailto:michael@freepascal.org" target="_blank">michael@freepascal.org</a>></span><br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div class="HOEnZb"><div class="h5"><br>
On Mon, 23 Sep 2013, Mattias Gaertner wrote:<br>
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
On Mon, 23 Sep 2013 11:46:54 +0200 (CEST)<br>
Michael Van Canneyt <<a href="mailto:michael@freepascal.org" target="_blank">michael@freepascal.org</a>> wrote:<br>
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
On Mon, 23 Sep 2013, Zaher Dirkey wrote:<br>
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
On Mon, Sep 23, 2013 at 10:02 AM, Michael Van Canneyt <<a href="mailto:michael@freepascal.org" target="_blank">michael@freepascal.org</a>> wrote:<br>
Var<br>
C : TBaseObjectClass;<br>
begin<br>
C:=TBaseObjectClass(ClassType)<u></u>;<br>
Result:=C.Create;<br>
end;<br>
<br>
Yes, that help me, thanks.<br>
<br>
Now about assigning I must repeat it (assign) for every child class copy its field members, is there any trick to copy the values like assigning record var to another record<br>
var?<br>
I know it is kind of strange way :P<br>
</blockquote>
<br>
There is no such safe mechanism.<br>
</blockquote>
<br>
Well, actually there is a safe mechanism. You use a record to store the<br>
class variables. But it looks clumsily:<br>
<br>
type<br>
TMyClass = class(TPersistent)<br>
private<br>
type<br>
TMyClassVars = record<br>
a,b,c: string;<br>
end;<br>
private<br>
F: TMyClassVars;<br>
public<br>
procedure Assign(Source: TPersistent);<br>
property a: string read F.a write F.a;<br>
end;<br>
<br>
procedure TMyClass.Assign(Source: TPersistent);<br>
begin<br>
F:=TMyClass(Source).F;<br>
inherited;<br>
end;<br>
</blockquote>
<br></div></div>
Yes. But that works only for 'simple' types and still requires you to write code.<br>
<br>
For the more general case where you can have arrays, classes, interfaces and whatnot as fields of your object, there is simply no correct way.<span class="HOEnZb"></span><br></blockquote></div><br></div><div class="gmail_extra">
Isn't there? Maybe it wouldn't be easy, but IIRC Delphi offers something related to this with TComponents and Streams. This Delphi mechanism I knew worked only for properties, but I found references that there existed a wider mechanism in D2010.<br clear="all">
</div><div class="gmail_extra"><br>-- <br>Frederic Da Vitoria<br>(davitof)<br><br>Membre de l'April - « promouvoir et défendre le logiciel libre » - <a href="http://www.april.org" target="_blank">http://www.april.org</a><br>
</div></div>