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

Posted on 1999-06-22
Medium Priority
Last Modified: 2010-04-06
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?

Question by:volavy
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2

Expert Comment

ID: 1384007
You can use many ways.
You can define your own type like this:

    resulttype = record
        FirstName: String
        SecondName: String


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

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.
LVL 13

Accepted Solution

Mirkwood earned 80 total points
ID: 1384008
Procedure Func1 (var ret1 : string; var ret2 as string)
  ret1 := "Arjen";
  ret2 := "Bos";
LVL 13

Expert Comment

ID: 1384009
I'm sorry, I'm dreaming.

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
Video by: ITPro.TV
In this episode Don builds upon the troubleshooting techniques by demonstrating how to properly monitor a vSphere deployment to detect problems before they occur. He begins the show using tools found within the vSphere suite as ends the show demonst…
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…
Suggested Courses

719 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question