Jump to content
Sign in to follow this  
bmw74

StdOut buffer getting filled?

Recommended Posts

bmw74

HI everyone,

I have an app that is reading the Console output with a similar procedure as suggested in the help. Here is part of the code that I am currently using for this purpose:

$Output = GUICtrlCreateEdit("", 8, 304, 449, 257, BitOR($ES_AUTOVSCROLL, $ES_NOHIDESEL, $ES_READONLY, $ES_WANTRETURN, $WS_VSCROLL))
..
..
$ConsoleCLI = <here goes the command that will run in the console>
..
..
$StartTimer = TimerInit()
$PID = Run(@ComSpec & " /c " & $ConsoleCLI, $InstalledDir, @SW_HIDE, $STDERR_MERGED)

While 1
    $line = StdoutRead($PID)
    If @error Then ExitLoop
    GUICtrlSetData($Output, $line, 1)  ;Write to the $Output input box
    If $line <> "" Then
        _Log($line)
        $x = $x+1
        $outputText[$x] = $line
    EndIf
    If StringInStr($outputText[3], "Error") <> 0 Then
        MsgBox(16, "Error", $outputText[3] & @CRLF & $outputText[4] & @CRLF & $outputText[5])
        ProcessWaitClose ($PID)
        $StopTimer = TimerDiff($StartTimer)
        _SendMessage(GUICtrlGetHandle($progress), $PBM_SETMARQUEE, False) ;stop progress bar
        Return(1)
    EndIf
WEnd

ProcessWaitClose ($PID)
$StopTimer = TimerDiff($StartTimer)

The code is working as expected, except that when I am running a very long operation, at some point the input screen (defined as $output) is not being populated anymore. I have a progress bar that is active while the process is running, and the progress bar remains active until the process has completed, so I know the script is still running and is not locked, but for some reason my output box is not updating anymore.

My theory is that the STDOUT buffer is getting filled, and since I am not releasing it until the whole operation has ended (ProcessWaitClose ($PID)), it is not able to update more on the screen, although the script is in fact running in the background and doing what its supposed to do.

I hope the above code snippet provides enough information for someone to help me out here. If my theory is correct, I basically need one of the following:

- How to detect when the STDOUT buffer is filled, and release it

or

- How to preallocate the buffer size, so I can increase it before the operation starts

Of course any other suggestion is welcomed.

Thanks for your help!

Share this post


Link to post
Share on other sites
bmw74

Sorry I came late.

You edit box is full use GUICtrlSetData($Output, '') To clear it once in a while

Sorry for taking a while to respond. I implemented your suggestion, and although I don't believe it has completely fixed the problem (since I am still getting it once in a while), it has improved the behavior tremendously. Basically I clean the edit window for every command I run, whereas before I was running an appended long stream.

Thanks for your help!

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.