I should probably also note that you shouldn't use move with records that have ansistrings or other dynamically allocated variables in them..

On 5/15/2018 6:49 PM, Alexander Grotewohl wrote:
type
  TRec = record
    s1:string;
    i1:integer;
  end;

var
  S1,S2:string;
  R1,R2:TRec;
begin
  S1:='123';
  S2:=S1; // lol

  R1.s1:='123';
  R1.i1:=1;
  move(R1, R2, sizeof(TRec));
  writeln(R2.s1, ' ', R2.i1);
end.


On 5/15/2018 2:39 PM, denisgolovan wrote:
Well.

"Copy" works for arrays only.
Neither strings nor records work.
Tested in pretty old svn rev. 37656

//=================================================
program project1;

{$mode objfpc}{$H+}

type
   TRec = record
     s1:string;
     i1:integer;
   end;

var S1,S2:string;
     A1,A2:array of integer;
     R1,R2:TRec;
begin
   A1:=[1,2,3];
   A2:=Copy(A1);
   A2[0]:=10;
   writeln(A1[0]);
   writeln(A2[0]);

   S1:='123';
   S2:=Copy(S1);

   R1.s1:='123';
   R1.i1:=1;
   R2:=Copy(R1);
end.
//===========================================

BR,
Denis
_______________________________________________
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

_______________________________________________
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

_______________________________________________
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Reply via email to