[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 364
  • Last Modified:

Function with a TStrings result

I need to write a function with a TStrings result. I would really appreciate some examples.
0
skymag
Asked:
skymag
1 Solution
 
MotazCommented:
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
 
markshifferCommented:
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
 
skymagAuthor Commented:
Thanx!
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now