How to copy array? How to copy array? arrays arrays

How to copy array?


Why not use FOR?

SetLength(DataR,Length(input));for i:=Low(input) to High(input) do  DataR[i]:=input[i];

BTW: if you want to have arrays passing as parameter, you should declare them as a type, eg:

type  TMyArray = array of byte;

and use TMyArray as parameters type.

Edit: I was notified about i lower value. In my original post it was for i:=0, but i:=Low(input) is safer and more pure.


try this

type  TByteDynArray = array of Byte;function CopyData(const Input:array of Byte):TByteDynArray;begin  SetLength(Result, Length(Input));  Move(input[0], Result[0], Length(Input));end;


Try:

class procedure TCelebrity.BeginRead(var input:Array of byte);var DataR:Array of byte;begin  VirtualFree(@DataRead,High(DataRead),MEM_RELEASE);  SetLength(DataR,Length(input));  Move(input[0],DataR,Length(input));end;