yadav Posted August 22, 2007 Posted August 22, 2007 I am using different functions of IE.au3 in my own function,eg: I am using _IEformgetcollection(),IEformgetelementCollection()..etc when any of this functions throws a error,I don't want to stop the execution of my script,can any body please send me the syntax for this,thanks.
PsaltyDS Posted August 22, 2007 Posted August 22, 2007 I am using different functions of IE.au3 in my own function,eg: I am using _IEformgetcollection(),IEformgetelementCollection()..etcwhen any of this functions throws a error,I don't want to stop the execution of my script,can any body please send me the syntax for this,thanks._IEErrorHandlerRegister() 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
yadav Posted August 22, 2007 Author Posted August 22, 2007 _IEErrorHandlerRegister() with this function how can i know what errors it raised and how to catch them can you please send me some syntax,becasue based on error i want to manupulat the functionality of my script, thanks.
PsaltyDS Posted August 22, 2007 Posted August 22, 2007 with this function how can i know what errors it raised and how to catch them can you please send me some syntax,becasue based on error i want to manupulat the functionality of my script, thanks.You show me your code, I'll show you mine... 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
yadav Posted August 23, 2007 Author Posted August 23, 2007 You show me your code, I'll show you mine... Example Code: Func Test() $oFrame=_IEFrameGetCollection($oIE,2) $Form=_IEFormGetCollection($oFrame,0) $matter=_IEFormElementGetObjByName($Form,"order[matter]") $actFor=_IEFormElementGetObjByName($Form,"search[acting_for]") $purpofEnq=_IEFormElementGetObjByName($Form,"search[purpose]") $monitersrch=_IEFormElementGetObjByName($Form,"search[monitored]") EndFunc
PsaltyDS Posted August 23, 2007 Posted August 23, 2007 OK, all those function return either 0 for failure, or an object for success. So the only test required is "If IsObj($obj)" or alternatively you could test for "If $obj = 0". I did it this way to report the errors when the _Test() function returns: expandcollapse popup#include <IE.au3> ; Declarations assumed to have happened outside the function: Global $oIE, $oFrame, $Form, $matter, $actFor, $purpofEnq, $monitersrch _IEErrorHandlerRegister() ; To handle any COM errors $oIE = _IECreate("www.autoitscript.com") If _Test() Then MsgBox(64, "Success", "Ta Da!") Else MsgBox(16, "Failed", "_Test() failed: @error = " & @error & " @extended = " & @extended) EndIf ; ------------------------------------------- ; Function: _Test() ; Purpose: Retrieve selected objects from IE page ; Parameters: None ; On success: Sets new values to global variables and returns 1 ; On failure: Returns 0 and sets @error and @extended to indicated failed values ; ------------------------------------------- Func _Test() ; Get frame $oFrame = _IEFrameGetCollection($oIE, 2) If Not IsObj($oFrame) Then Return SetError(1, 1, 0) ; Get form $Form = _IEFormGetCollection($oFrame, 0) If Not IsObj($Form) Then Return SetError(1, 2, 0) ; Get various elements, set bits for any that fail Local $ErrExt = 0 $matter = _IEFormElementGetObjByName($Form, "order[matter]") If Not IsObj($matter) Then $ErrExt += 1 $actFor = _IEFormElementGetObjByName($Form, "search[acting_for]") If Not IsObj($actFor) Then $ErrExt += 2 $purpofEnq = _IEFormElementGetObjByName($Form, "search[purpose]") If Not IsObj($purpofEnq) Then $ErrExt += 4 $monitersrch = _IEFormElementGetObjByName($Form, "search[monitored]") If Not IsObj($monitersrch) Then $ErrExt += 8 If Not $ErrExt Then Return 1 Else Return SetError(2, $ErrExt, 0) EndIf EndFunc ;==>_Test 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
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