Joon Posted August 24, 2006 Share Posted August 24, 2006 Does AutoIt have anything similar to On Error Resume Next? I have wrote script to connect to multiple databases and perform maintenances. If everything is set right, it's working great. But if one entry have bad information like invalid password, whole script stops. And it doesn't handle by COM error handler instead i just get .Open^ ERROR . So, how do I need make my script ignore error message and keep going? Global $oMyError = ObjEvent("AutoIt.Error", "MyErrFunc") $ado = ObjCreate("ADODB.Connection") $file = FileOpen("config.txt", 0) While 1 $line = FileReadLine($file) If @error = -1 Then ExitLoop ; parse $line to get connection info. With $ado .ConnectionString = ("Provider='OraOLEDB.Oracle';Data Source='" & $DBSource & "';User Id='" & $UserID & "';Password='" & $Password & "';") .Open EndWith ; Some function here to get RecordSet $ado.Close WEnd FileClose($file) Func MyErrFunc() SetError(1) EndFunc Link to comment Share on other sites More sharing options...
Moderators big_daddy Posted August 24, 2006 Moderators Share Posted August 24, 2006 My suggestion would be to add this to the top of your script. #include <IE.au3> _IEErrorHandlerRegister() Link to comment Share on other sites More sharing options...
Joon Posted August 24, 2006 Author Share Posted August 24, 2006 (edited) My suggestion would be to add this to the top of your script. #include <IE.au3> _IEErrorHandlerRegister() Still gets an error on .Open with bad password. Edited August 24, 2006 by Joon Link to comment Share on other sites More sharing options...
Moderators big_daddy Posted August 24, 2006 Moderators Share Posted August 24, 2006 Still gets an error on .Open with bad password. Oops! Take this line out of your script. Global $oMyError = ObjEvent("AutoIt.Error", "MyErrFunc") Link to comment Share on other sites More sharing options...
Joon Posted August 24, 2006 Author Share Posted August 24, 2006 Oops! Take this line out of your script. Global $oMyError = ObjEvent("AutoIt.Error", "MyErrFunc")oÝ÷ Ûú®¢×¶)e}¨¥³Æ¦yê뢹²Æ y8b²+'£!jÒ7ök^²Ø§«¢+Ø(¥¹±Õ±Ðí%¹ÔÌÐì)}%ÉɽÉ!¹±ÉI¥ÍÑÈ ¤(ÀÌØí¼ô=© ÉÑ ÅÕ½Ðí=¹ ½¹¹Ñ¥½¸ÅÕ½Ðì¤)]¥Ñ ÀÌØí¼($¹ ½¹¹Ñ¥½¹MÑÉ¥¹ô ÅÕ½ÐíAɽ٥ÈôÌäí=É=1¹=ɱÌäìíÑM½ÕÉôÌäí=IÌäìíUÍÈ%ôÌäíUÍÉ9µÌäìíAÍÍݽÉôÌäí AÍÍݽÉÌäììÅÕ½Ðì¤($¹=Á¸)¹]¥Ñ )5Í ½à À°ÅÕ½ÐìÅÕ½Ðì°ÅÕ½Ðí¡±±¼ÅÕ½Ðì¤(ÀÌØí¼¹ ±½Í( I never get to MsgBox, I do get to it with a good password. Link to comment Share on other sites More sharing options...
SoftVoile Posted December 16, 2008 Share Posted December 16, 2008 is there no way to continue the script run if an error occured? i searched and found this (by: Weaponx) If you have your own error handler, place this at the top of your script Opt("RunErrorsFatal", 0) like Jos said. If you are in a loop you can do this: For $X = 1 to 10 $result = Ping("www.google.com") If @ERROR Then ContinueLoop MsgBox(0,"","Ping successful") Next by Jos there is no "On Error Resume Next" option in AutoIt3, but there are 2 things that can be set: Catching errors running a program: Opt("RunErrorsFatal", 1) ;1=fatal, 0=silent set @error Catching COm errors: CODE $oMyError = ObjEvent("AutoIt.Error","MyErrFunc"); Install a custom error handler ; This is my custom error handler Func MyErrFunc() $HexNumber=hex($oMyError.number,8) Msgbox(0,"","We intercepted a COM Error !" & @CRLF & _ "Number is: " & $HexNumber & @CRLF & _ "Windescription is: " & $oMyError.windescription ) SetError(1); something to check for when this function returns EndfuncoÝ÷ Ûú®¢×º×mºw^®ËZØhÂÚ¢+fÉìZ^r^jëh×6_Showhide("Second") _Showhide("Third") Func _Showhide($Title) If WinExists($Title, "") Then WinSetState($Title, "", @SW_HIDE) MsgBox(64, "Title", "Press ok to show window.", 10) WinSetState($Title, "", @SW_SHOW) MsgBox(64, "Title", "Press ok to Close the window.", 10) WinClose($Title, "") EndIf EndFunc ;==>_Showhide any help? Unresolved topics:1- Please help me in Editing or replacing a page in FireFox and IE.Please have a look at them. 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