I've never seen arrays being returned from a function - I'm not sure if it's possible. The way I have always seen it done is to pass the array into the procedure/function as a reference parameter (i.e. a parameter that will have its' values modified). A reference parameter is indicated by the var keyword. Here's an example of an open array (an array of any length) parameter:
Code:
procedure InitialiseToZero(var Arr: Array of Double)
var
i:integer;
begin
for i:= Low(Arr) to High(Arr) do
Arr[i] := 0;
end;
Rod is correct.
Also you will need to do this if you want to pass multi dimensional arrays INTO a function.
The previous examples use 'open array parameters' and these will only accept single dimensional arrays
Thanks due to Zathras for that.
Steve.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.