Link to home
Start Free TrialLog in
Avatar of volavy
volavy

asked on

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
Avatar of Tweety
Tweety

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.
ASKER CERTIFIED SOLUTION
Avatar of Mirkwood
Mirkwood

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
I'm sorry, I'm dreaming.