<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">2013/9/23 Mattias Gaertner <span dir="ltr"><<a href="mailto:nc-gaertnma@netcologne.de" target="_blank">nc-gaertnma@netcologne.de</a>></span><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>
<div class="im">Michael Van Canneyt <<a href="mailto:michael@freepascal.org">michael@freepascal.org</a>> wrote:<br>
<br>
><br>
><br>
> On Mon, 23 Sep 2013, Zaher Dirkey wrote:<br>
><br>
> ><br>
> > On Mon, Sep 23, 2013 at 10:02 AM, Michael Van Canneyt <<a href="mailto:michael@freepascal.org">michael@freepascal.org</a>> wrote:<br>
> > Var<br>
> > C : TBaseObjectClass;<br>
> > begin<br>
> > C:=TBaseObjectClass(ClassType);<br>
> > Result:=C.Create;<br>
> > end;<br>
> ><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>
><br>
> There is no such safe mechanism.<br>
<br>
</div>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></div><br></div><div class="gmail_extra">This wouldn't clone included objects. I mean: if the object to be cloned contains objects, those included objects should probably be cloned too, but putting them into a record wouldn't achieve that.<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>