Board index » delphi » Returning TStringLists From function

Returning TStringLists From function

It is not too taxing to have one function create a string list and pass
its values to another string list, but I have found it difficult to pass
them from unit to unit.  I have a unit that performs a certain function
like interacting with some specific hardware.  I want to be able to call
that unit's string list creating function from another unit and it
doesn't work, or more probably, I can't sort it out.

Can anyone help?

--
  <HTML>
  Dean W. Johnson
  <BR>home page: <A HREF="My Home
Page">https://members-central.home.net/deanwj/deanwj.html</A></HTML>

 

Re:Returning TStringLists From function


Do not pass TStringList as a parameter, instead pass the parameter as
TStrings which is the abstract ancestor class.

procedure p1;
var TS : TStringList;
begin
    p2(TS);
    with TS do
         begin
                {work with it}
        end;
end;

procedure p2(MyStrings : TStrings);
begin
        MyStrings := TStringList.Create;
end;

Quote
Dean W. Johnson wrote in message <36CD03CD.BED3C...@home.com>...
>It is not too taxing to have one function create a string list and pass
>its values to another string list, but I have found it difficult to pass
>them from unit to unit.  I have a unit that performs a certain function
>like interacting with some specific hardware.  I want to be able to call
>that unit's string list creating function from another unit and it
>doesn't work, or more probably, I can't sort it out.

>Can anyone help?

>--
>  <HTML>
>  Dean W. Johnson
>  <BR>home page: <A HREF="My Home
>Page">https://members-central.home.net/deanwj/deanwj.html</A></HTML>

Other Threads