[fpc-pascal] Question about Deleting elements in Dynamic Array

Henry Vermaak henry.vermaak at gmail.com
Wed Apr 28 11:14:40 CEST 2010


On 28 April 2010 05:33, Bihar Anwar <bihar_anwar at rocketmail.com> wrote:
> I've tried to use Move() instead of Copy(). Any objection with the following code?
>
> var
>  a: array of string;
>
> SetLength(a, 5);
> a[0] := 'aa'; a[1] := 'bb'; a[2] := 'cc'; a[3] := 'dd'; a[4] := 'ee';
>
> System.Move(a[3], a[0], 2 * SizeOf(string) );    // instead of  a := Copy(a, 3, 2);
> SetLength(a, 2);

You'll have to finalize the strings you are overwriting.

Henry



More information about the fpc-pascal mailing list