gamingmouse Posted April 23, 2009 Share Posted April 23, 2009 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 Link to comment Share on other sites More sharing options...
BinaryBrother Posted April 24, 2009 Share Posted April 24, 2009 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... SIGNATURE_0X800007D NOT FOUND Link to comment Share on other sites More sharing options...
gamingmouse Posted June 30, 2009 Author Share Posted June 30, 2009 If anyone else runs into this, the following change fixes the problem: case $msg = 0 If $gPID = 0 Then ContinueLoop StdoutRead($gPID,1) If @extended = 0 Then ContinueLoop $line = StdoutRead($gPID) If @error Then ContinueLoop Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now