Jump to content
Sign in to follow this  
gamingmouse

StdoutRead Code Stopped Working With New AI version

Recommended Posts

gamingmouse

Hi,

I'd been using the code below to read stdout output from a DOS program which is started by my AI program using the Run command, and display that output in real time in a GUI edit box. The AI program has worked fine for over a year, but when I upgraded to the latest version of AI and recompiled using that, the program no longer produces any output in the edit box. The DOS program is definitely still being started by AI successfully, since it behavior is identical to before. The only difference is the lack of output. Thanks for any ideas for fixing this.

Jonah

case $msg = 0
            If $gPID = 0 Then ContinueLoop
            $iCharsAvailable = StdoutRead($gPID,0,1)
            If $iCharsAvailable = 0 Then ContinueLoop
            $line = StdoutRead($gPID)
            If @error Then ContinueLoop
            
        ;MsgBox(0, "STDOUT read:", $line)
            If $line <> "" Then
                GUICtrlSetData($editBox, $line, "*")
            EndIf
            
            $strEdit = GUICtrlRead($editBox)
            $arrEditLines = StringSplit($strEdit, @LF)
            $last = $arrEditLines[0]-1
            If $last > 1200 Then
            ;$arrTemp = _ArraySub($arrEditLines,$last-1200,$last)
                $strTemp = _ArrayToString($arrEditLines, @LF, $last-1000, $last)
                GUICtrlSetData($editBox, $strTemp)
            EndIf

Share this post


Link to post
Share on other sites
BinaryBrother

StdoutRead(), StderrRead() and ConsoleRead() have undergone significant changes. They no longer block, they return immediately. The parameters have changed as well. It's no longer possible to read count parameters. The peek parameter has moved to the second parameter. The third parameter now specifies you want the data to be returned in binary format (default is text). The macro @extended now holds the number of bytes/characters read.

Not sure if that's your problem or not, regardless there is no way to tell if there is a bug in the new code, without seeing the code or being able to reproduce the error... The line you are somewhat spotlighting,
GUICtrlSetData($editBox, $line, "*")
... May simply have nothing to do with that function, but rather the code that readies that function for it's use, according to the structure of your code.

In other words... You highlighted inconclusive code, and are reporting an error that doesn't have a bug-report, nor based on the limited amount of input look erroneous. Based on that statement I would say 1 of the following is possible...

Your script was broken by an AutoIt update, but if so you would more than likely be receiving an error...

Your syntax is correct with some sort of other underlying issue, made any other changes to the system that would break the script?

P.S. The 'bug' statement above is not implicating AutoIt, I am referencing your script now possibly has bugs/bad-code due to the new changes.

Oh.. I'm tired so if I messed something up, or sound 'brash'... Early apologies... ^_^

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.