Maybe I got it wrong...
In my view, what you need is to perform a
dynamycal analyisis on the output of the console.
That is more difficult, since you need to know
precisely if the output is something formatted as lines. Otherwise, you end up with an endless string which has only one line, which is always "the last line". So we're in a vicious cricle here:
what is "last line"?
If I understood it right, the first step would to direct the output from the console, into a string variable.
As an intermediate phase, you load it into a TextArea and get the image on how it looks like:
All you need here is a FMain module and a TextArea1 control.
To trigger the process, put a Button1 above the TextArea1, then on Button1_Click() event, call the procedure that does the Shell or Exec. Say...
'---
Public Sub GetConsoleOutput()
'--- Code for spying the console.
End
'---
Public Sub Button1_Click()
GetConsoleOutput()
End
'--- This goes into FMain.Class:
Dim strConsoleOutput, strToken, strCurrentLine As String
'...
TextArea1.Wrap=False
TextArea1.Text=strConsoleOutput
'--- Now, how does it look like? Do we have lines?
'--- IF so, then we cycle through the lines, using a Stream, then a clause.
'... stream Dim ,open etc.
While Not hndStream.EOF
If InStr(strToken ,strCurrentLine) Then '--- We found what we're looking for. Do the job we need.
DoTheJobINeed()
Else '--- We might need to do something here. Either ignore the line since we are missing what we are looking for, OR whatever else.
DoTheAlternateJob()
End If
Wend
If you do this, you need to set the Wrap property to "False ", to prevent wrapping the contents. This is how you find out if there is only one string, or there are more lines.
In the code above, I admitted
by default that
we got LINES. That is, more than one line, which is always "LastLine".
NOTE:
I wrote the code in place from memory so YOU GOT TO TEST IT, and obviously, fill the required lines to catch the console output into the string [strConsoleOutput].
Since I hate console, I leave it up to you to write the appropriate code.
...
The other way around...
I have to figure out how to do this, because it goes beyond my understanding how you can test a string that is continuously generated and you want to find something in it, in real time. Meaning, as it is generated.
---
The other thing you need to do, is write the code for the Stream: to open it, read the lines from [strConsoleOutput] into [strCurrentLine] and test the [strToken]
As I said though,
maybe I got it wrong...