New Question :
What if i have an Object wich Sores another Object (for Example Linked lists). how do i copy the "Neighbours" ?
Example:
//input
GetElement(Sel).DeepCopyTo(ElemBefore); //Works
GetElement(Sel).nextBtl.DeepCopyTo(ElemBefore.nextBtl); //Not work
GetElement(Sel).prevBtl.DeepCopyTo(ElemBefore.prevBtl); //Not work
//Output
IF GetElement(m3D).nextBtl.Equals(ElemBefore.nextBtl) then begin
ShowMessage('Deep Copy did not Work'); //this message is shown
end;
IF GetElement(m3D).Equals(ElemBefore) then begin
ShowMessage('Deep Copy did not Work'); //this message is NOT shown
end;
//Copy Function
procedure TElement.DeepCopyTo(Element :TElement);
begin
Element.BtlNum := fBtlNum;
Element.BtlArtNum := fBtlArtNum;
Element.ZLAL := fZLAL;
Element.Moved := fMoved;
Element.prevBtl := fprevBtl;
Element.nextBtl := fnextBtl;
Element.Data := fData;
Element.Split:= fSplit;
Element.Coords := fCoords;
end;
Did some Testing here are the Results :
###################################
COPY OF CURRENT(NOT CHANGED(Should) ) OBJECT ->
###################################
ElemBefore = <TELEMENT> = {
<TOBJECT> = {
_vptr$ = {
0xc026c8,
0x5}},
FBTLNUM = 5,
FBTLARTNUM = 0,
FZLAL = 0,
FMOVED = DIRNONE,
FNEXTBTL = $a1e3dc8,
FPREVBTL = $a1e1dc8,
FCOORDS = {
X = 15,
Y = 3,
Z = 0},
FDATA = 0,
FSPLIT = SPNEXT}
var
ElemBefore: TElement =
class
(TObject)
###################################
CURRENT (CHANGED) OBJECT ->
###################################
TempElem = <TELEMENT> = {
<TOBJECT> = {
_vptr$ = {
0xc026c8,
0x5}},
FBTLNUM = 5,
FBTLARTNUM = 0,
FZLAL = 0,
FMOVED = DIRNONE,
FNEXTBTL = $a1e3dc8,
FPREVBTL = $a1e1dc8,
FCOORDS = {
X = 15,
Y = 3,
Z = 0},
FDATA = 0,
FSPLIT = SPNONE}
var
TempElem: TElement =
class
(TObject)
#########
They still have the same adress ... can someone help/explain this to me ?