Solved

Function with a TStrings result

Posted on 2000-03-22
3
331 Views
Last Modified: 2010-05-18
I need to write a function with a TStrings result. I would really appreciate some examples.
0
Comment
Question by:skymag
3 Comments
 
LVL 7

Accepted Solution

by:
Motaz earned 50 total points
ID: 2644448
function GetList: TStrings;
begin
  Result:= TStringList.Create;
  Result.CommaText:= 'First,Second,Third';
end;

//How to use it:

procedure TForm1.Button1Click(Sender: TObject);
var
  MyList: TStrings;
begin
  MyList:= GetList;
  ShowMessage(MyList.Text);
end;


Motaz
0
 
LVL 3

Expert Comment

by:markshiffer
ID: 2644668
Its better to use a procedure with a var param when passing objects. Just thought I would tone that in. I've been in the same place of needing to pass an object back as the result of a function and it is much more trouble than it is worth...
0
 

Author Comment

by:skymag
ID: 2644691
Thanx!
0

Featured Post

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

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

Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

786 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