Size Buffer DataAvailable/ResultReturned

In 2019 r2, DataAvailable has been deprecated and replaced with ResultReturned. I don’t think that the issue I am having has anything to do with this.
I am currently using ResultReturned as the Event that fires off my code. I am using a Shell controller that has been dragged into my window. It is “monitoring” what the Shell script produces by the ResultReturned Event.

My problem is that the Shell is producing some text that I am trying to bring into Xojo using the ResultReturned event which “notifies” (so to speak) Xojo and then you can retrieve this text with a Shell.ReadAll command. When the amount of text is small, this is working just fine. When the amount of text is larger, I get problems. Only part of the text is retrieved. When I say larger, I mean about 4K so this is not something that is huge.

So anyway, my program is doing fine until the Shell puts something slightly large in the buffer. Then I only retrieve some of it. When I look at what I am able to retrieve, it seems to be about 4,200 characters. It seems to vary slightly.

My needs are not to be able to handle MBs of text. At most I need to be able to handle about 25,000 characters at a time.

I have little experience with this sort of thing. I am guessing that there is some “buffer” that has a size limitation. What I would like to be able to do is change that buffer size (if my speculation is correct) or write some code somehow that “gets around” this problem.

Purely a guess, but …

Does the ResultReturned event fire multiple times? If so, perhaps you can have your own buffer, and keep appending results to it until it’s done.
The problem them becomes “how do I know it’s done”.

Thanks for the reply. SInce I wrote the note, I had managed to succeed with a clumsy bit of code. I would mark the text that I was trying to get with an arbitray end of message marker. When the Shell code gets to an input() line, the Shell code stops and Xojo gets a ResultReturned event and sucks up all (or if there was too much to send) just some of what is in the buffer.

My solution (when I did not get the entire text) was to send a message back to the Shell asking for more. I would put the input() line of code in a loop and keep going.

back_from_xojo = input() # Now Python pauses and notifies Xojo that there is material to send # Xojo grabs information. If it sends back need more while back_from_xojo == "NeedMore": back_from_xojo = input() # Python pauses and notified Xojo more info

This required a loop in the Shell code.

I did not stumble on the idea suggested in your note, that I did not have to bother with the loop in the Shell code and that I would simply get repeated ResultReturn events until the entire buffer had been sent. So now I have done as you suggested. I keep a property that stores the incoming, incomplete text. The event continues to fire, without any effort on my part, until all the data has been sent.

If the code in the ResultReturned event does not see the end of message marker, it simply stores it. Future incoming data is simply appended to it. When it see the end of message marker, it knows that it has gotten all that it needs, and the work can proceed.

Your “purely a guess” has made my life a lot easier.

Just fyi, this is considered the “standard” approach. Well done!