How can I make a function return more than one value ?

I would like my function to return more than one string. Let's say I feed the function with a string, and then it returns eg. my first and my second name. How do I syntax the function?

/Peter
volavyAsked:
Who is Participating?
 
MirkwoodConnect With a Mentor Commented:
Procedure Func1 (var ret1 : string; var ret2 as string)
begin
  ret1 := "Arjen";
  ret2 := "Bos";
end;
0
 
TweetyCommented:
You can use many ways.
You can define your own type like this:

type
    resulttype = record
        FirstName: String
        SecondName: String
    end;

...

function SplitName(Name: String): resulttype;
var
    Name1, Name2: String;
begin
    ....
    result.^FirstName := Name1;
    result.^SecondName := Name2;
end;

Another Way is to use a procedure by using parameters by reference.
You can use a TList or aTStringlist object as functiunresult.
and many many more.
0
 
MirkwoodCommented:
I'm sorry, I'm dreaming.
0
All Courses

From novice to tech pro — start learning today.