A-man Posted September 13, 2012 Share Posted September 13, 2012 Is it possible to have a function return a 1 dimensional array? I have this: function arr(): array of integer; begin result[0] := 0; result[1] := 1; result[2] := 2; result[3] := 3; end; // later i have this blah := arr(); I'm just trying to get the fundamentals down. It doesn't throw any syntax errors, so it seems like it should work. I also noticed that the function doesn't show up in the function list if it is an array of (something). Quote Link to comment Share on other sites More sharing options...
FHannes Posted September 14, 2012 Share Posted September 14, 2012 You should replace "array of integer" with TIntArray, afaik by default in pascal it's not allowed to return an "array of", though it's possible that SCAR's engine supports it. Quote Link to comment Share on other sites More sharing options...
A-man Posted September 14, 2012 Author Share Posted September 14, 2012 Alright, that works. Thanks Quote Link to comment Share on other sites More sharing options...
Janilabo Posted September 14, 2012 Share Posted September 14, 2012 Yehp: function Test: array of Integer; // Can be replaced with TIntArray, both ways work. begin Result := [1231, 342, 53463, 2353]; { Other way: SetLength(Result, 4); Result[0] := 1231; Result[1] := 342; Result[2] := 53463; Result[3] := 2353; } end; var tmp: TIntArray; begin ClearDebug; tmp := Test; WriteLn('tmp: ' + TIAToStr(tmp)); SetLength(tmp, 0); end. Quote Link to comment Share on other sites More sharing options...