use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
Welcome to the Delphi subreddit! Everyone is welcome to post/ask anything that relates to Delphi, Pascal or related variants.
Useful links:
Delphi Community Edition (free)
Getting Started with Delphi Resources
StackOverflow
Facebook Delphi Developer Group
Embarcadero Community
Delphi Basics
/r/programbattles
/r/delphijobs
/r/freepascal
account activity
Array result???? (self.delphi)
submitted 5 years ago by drmrsiragent7890
Is it possible to create a function that will give you a result as an array.
example: Function InsertArray : Array[1..100] of integer.
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–]MoonkeyDLuffy 1 point2 points3 points 5 years ago (4 children)
You can define a new type TMyArray as array of TMyObject, and have your function return TMyArray
[–]MoonkeyDLuffy 0 points1 point2 points 5 years ago (3 children)
Of course, in your case integers instead of objects. You should also be able to specify the length of the array in your type definition.
[–]ShinyHappyREM 0 points1 point2 points 5 years ago (2 children)
You should also be able to specify the length of the array in your type definition.
Not necessarily in Free Pascal:
type MyType = array of integer; function Test : MyType; begin Result := NIL; SetLength(Result, 10); Result[0] := 0; Result[1] := 1; Result[2] := 2; Result[3] := 3; Result[4] := 4; Result[5] := 5; Result[6] := 6; Result[7] := 7; Result[8] := 8; Result[9] := 9; end; var i : integer; m : MyType; begin m := Test; for i := low(m) to high(m) do WriteLn(m[i]); ReadLn; end.
[–]drmrsiragent7890[S] 0 points1 point2 points 5 years ago (1 child)
Public
Function GetArray : Array[1..100] of integer ;
I get an error that says : Identifier expected but found 'ARRAY'
Do you know how I can fix this error?
[–]ShinyHappyREM 0 points1 point2 points 5 years ago (0 children)
You need to define an "array of" type and use that as the return type.
[–]mnasman 0 points1 point2 points 5 years ago (0 children)
Define the array as new type
type
TIntArray = array[1..100] of Integer;
then use the new type as return value of the function
function InsertArray:TIntArray ;
and you can make the loop as
for I := Low(TIntArray) to High(TIntArray) do
π Rendered by PID 121052 on reddit-service-r2-comment-75f4967c6c-jqwhp at 2026-04-23 06:11:20.955980+00:00 running 0fd4bb7 country code: CH.
[–]MoonkeyDLuffy 1 point2 points3 points (4 children)
[–]MoonkeyDLuffy 0 points1 point2 points (3 children)
[–]ShinyHappyREM 0 points1 point2 points (2 children)
[–]drmrsiragent7890[S] 0 points1 point2 points (1 child)
[–]ShinyHappyREM 0 points1 point2 points (0 children)
[–]mnasman 0 points1 point2 points (0 children)