[fpc-pascal] Copy dynamic array

denisgolovan denisgolovan at yandex.ru
Tue May 15 20:39:34 CEST 2018


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



More information about the fpc-pascal mailing list