Function with a TStrings result

I need to write a function with a TStrings result. I would really appreciate some examples.
skymagAsked:
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

x
 
MotazConnect With a Mentor Commented:
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
All Courses

From novice to tech pro — start learning today.