Yes, thank you. The best thing I've learned is to be suspicious of examples...

I've got it now, thank you all for the assistance.

I took AStringList.Add() to mean that it added the string to the list
of strings - I was wrong..

I did note that the example said that it was flawed, but, foolishly,
as it turned out, I thought it meant 'flawed' rather than 'doesn't
work at all'.



On 21 May 2014 18:33, waldo kitty <wkitt...@windstream.net> wrote:
> On 5/21/2014 7:00 AM, Peter Brooks wrote:
>>
>>    AStringList.LoadFromStream(Aprocess.Output);
>>    AStringList.LoadFromStream(AProcess.Stderr);
>>    AStringList.LoadFromStream(AProcess.Output);
>
>
> [quote]
> LoadFromStream loads the contents of Stream into the stringlist. Each line
> in the stream (as marked by the end-of-line marker of the particular OS the
> application runs on) becomes one string in the stringlist. This action
> replaces the contents of the stringlist, it does not append the strings to
> the current content.
> [/quote]
>
> those LoadFromStream calls are overwriting the contents of your
> stringlist... note the last sentence in the above quote from
> http://www.freepascal.org/docs-html/rtl/classes/tstrings.loadfromstream.html
>
> you need to figure out how to run through your streams and AStringList.Add()
> the entries to your stringlist
>
> *OR*
>
> you need to have another set of stringlists for those process outputs and
> then use AStringList.AddStrings()
>
> *OR*
>
> you need to AStringList.Assign() another string list, print/save it,
> AStringList.Assign() the next string list, print/save it and so on... as
> LoadFromStream, Assign replaces the current contents of AStringList with the
> new contents...
>
>
> FWIW: if you are using the "improved example" on
> http://wiki.freepascal.org/Executing_External_Programs then you should note
> that it does state that it is flawed and that you should use the code in the
> next example "reading large output" which waits till the end and then loads
> the stream into the stringlist and then you can manipulate it from there...
>
> --
>  NOTE: No off-list assistance is given without prior approval.
>        Please *keep mailing list traffic on the list* unless
>        private contact is specifically requested and granted.
>
> _______________________________________________
> fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
> http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
_______________________________________________
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Reply via email to