Bob Wya Posted April 27, 2007 Share Posted April 27, 2007 HiJust wanted some advice on the best way to debug GUI AutoIt scripts. I'm trying using the option in Scite to add alternating trace lines to all the linesin my code. The problem is that these then alter the @error return values that my script receives.E.g. ConsoleWrite('>Error code: ' & @error & @crlf & @crlf & '@@ Trace(1646) : $line = FileReadLine($handle)' & @crlf) ;### Trace Console $line = FileReadLine($handle) While (@error = 0) ConsoleWrite('>Error code: ' & @error & @crlf & @crlf & '@@ Trace(1649) : $percent= (100 * $i_file) / $total_files' & @crlf) ;### Trace Console $percent= (100 * $i_file) / $total_files ConsoleWrite('>Error code: ' & @error & @crlf & @crlf & '@@ Trace(1651) : GUISwitch($status_bar_handle)' & @crlf) ;### Trace Console GUISwitch($status_bar_handle) GUICtrlSetState($control_progress_status,$GUI_SHOW) ConsoleWrite('>Error code: ' & @error & @crlf & @crlf & '@@ Trace(1654) : GUICtrlSetData ($control_progress_status,$percent)' & @crlf) ;### Trace Console GUICtrlSetData ($control_progress_status,$percent) ConsoleWrite('>Error code: ' & @error & @crlf & @crlf & '@@ Trace(1656) : GUISwitch($main_window_handle)' & @crlf) ;### Trace Console GUISwitch($main_window_handle) $i_file += 1 ConsoleWrite('>Error code: ' & @error & @crlf & @crlf & '@@ Trace(1659) : $i=StringInStr($line, "=", 0, 1)' & @crlf) ;### Trace Console $i=StringInStr($line, "=", 0, 1) ConsoleWrite('>Error code: ' & @error & @crlf & @crlf & '@@ Trace(1661) : If ($i>0) Then _ArrayInsert($new_backup_files, $i_file, StringTrimLeft($line, $i) )' & @crlf) ;### Trace Console If ($i>0) Then _ArrayInsert($new_backup_files, $i_file, StringTrimLeft($line, $i) ) ConsoleWrite('>Error code: ' & @error & @crlf & @crlf & '@@ Trace(1663) : $line = FileReadLine($handle)' & @crlf) ;### Trace Console $line = FileReadLine($handle) ConsoleWrite('>Error code: ' & @error & @crlf & @crlf & '@@ Trace(1665) : WEnd' & @crlf) ;### Trace Console WEndThis went into an infinite loop because the @error return value of the FileReadLine() call at the end of the while loop isused to control the termination of the loop!! Obviously the ConsoleWrite() command clears the @error value!! Is the insertedtrace code designed to avoid such side-effects (like how no trace is inserted between the FileReadLine() call and the test at the start of the while loop). Maybe I've just stumbled across a small bug in it?? Obviously I just manually removed the offending(bold) trace line.Thanks for any help you guys can give!! Bob Wya Link to comment Share on other sites More sharing options...
PsaltyDS Posted April 27, 2007 Share Posted April 27, 2007 The macros @error and @extended are only valid IMEDIATELY after the function that sets them. In your script, the first time While tests the value @error was set by the line: $line = FileReadLine($handle)oÝ÷ ØKÞ¯+bëa® Ø^)iû^®ØZµhb謵ë-x®º+~º&¶¢ÛhX§y«¢+Ù ½¹Í½±]É¥Ñ ÌäìÐíÉɽȽèÌäìµÀìÉɽȵÀìɱµÀìɱµÀìÌäíQÉ ÄØØÔ¤è]¹ÌäìµÀìɱ¤ìQÉ ½¹Í½±oÝ÷ Øò¢ìÛh±«Þzºè®Úç$«^®Ø§jö«¦åzX¤y«¢+Ù}5åչѥ½¸ ¤(ÀÌØíÉÉMØôÉɽÈ(ÀÌØíáÑMØôáѹ((츸¸()%ÀÌØíÉÉMØQ¡¸(5Í ½à ÄØ°ÅÕ½Ðí=5ÌÌìÅÕ½Ðì°ÅÕ½Ðí¸ÉɽȽÕÉÌÌìÅÕ½Ðì¤)¹% Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law 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