Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-pascal / 2007-01

Copy and Dynamic Arrays

3 messages · 3 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Graeme Geldenhuys

Hi,

How do I copy Dynamic Arrays? I can't do what I used to in Delphi, using the Copy() function, as FPC keeps telling me I have the wrong number of parameters.

Doesn't FPC supporting copying dynamic arrays?

I have the following code which works in Delphi

---------------------
procedure TSomeClass.FooBar(AArray: array of string);
var
 lArray: array of string;
begin
  lArray := Copy(AArray);
  .....
end;
---------------------
From the Kylix help:

------------------------------
Note: When S is a dynamic array, you can omit the Index and Count parameters and Copy copies the entire array.

Graeme Geldenhuys There's no place like S34° 03.168' E018° 49.342'

Reply by email

Henry Vermaak
to Graeme Geldenhuys
Show quoted text 19 lines
Hi, How do I copy Dynamic Arrays? I can't do what I used to in Delphi, using the Copy() function, as FPC keeps telling me I have the wrong number of parameters. Doesn't FPC supporting copying dynamic arrays? I have the following code which works in Delphi --------------------- procedure TSomeClass.FooBar(AArray: array of string); var lArray: array of string; begin lArray := Copy(AArray); ..... end; ---------------------

i don't think you can do this. you should probably try:

b := copy(a, low(a), length(a));

otherwise there's fpc_dynarray_copy here:
http://community.freepascal.org:10000/docs-html/rtl/system/fpc_dynarray_copy.html

dunno how to use it, though.

henry

Reply by email

Florian Klaempfl
to Graeme Geldenhuys: How do I copy Dynamic Arrays? I can't do what I used to in Delphi, using the Copy()…
Show quoted text 16 lines
Hi, How do I copy Dynamic Arrays? I can't do what I used to in Delphi, using the Copy() function, as FPC keeps telling me I have the wrong number of parameters. Doesn't FPC supporting copying dynamic arrays? I have the following code which works in Delphi --------------------- procedure TSomeClass.FooBar(AArray: array of string); var lArray: array of string; begin lArray := Copy(AArray);

Submit a bug report if this works in delphi.

Reply by email