cyanidemonkey Posted January 29, 2006 Posted January 29, 2006 When I run this code below and there is no internet connection I get an no object error when the code reaches the For loop. I'd like a more user friendly way of saying there is no net connection, how do I do this with the xml object? Func _GetIP() Local $xmldoc = ObjCreate('Microsoft.XMLDOM'), $ip If Not IsObj($xmldoc) Then Return -1 $xmldoc.async = False $xmldoc.load ('http://www.ippages.com/xml/') For $x In $xmldoc.documentElement.childNodes If $x.NodeName = "ip" Then $ip = $x.text ExitLoop EndIf Next $xmldoc = 0 Return $ip EndFunc My AutoIt Scripts.- AutoHost and Password Enabler for Delta Force 2 Demo.| Caffine for Winamp 2.9x and WRS 2.0 | mp3 directory cleaner | CRAP DJ | A:B:J Radio Automation Software | FFMPEG batch conversion automator
Confuzzled Posted January 31, 2006 Posted January 31, 2006 Idea #1: If you check how many $xmldoc.documentElement.childNodes there are, won't they be zero where the connection is down?Idea #2: How about in COM error handling code?Idea #3: How about a valid value for @IPAddress1?
billmez Posted January 31, 2006 Posted January 31, 2006 When I run this code below and there is no internet connection I get an no object error when the code reaches the For loop. I'd like a more user friendly way of saying there is no net connection, how do I do this with the xml object? Func _GetIP() Local $xmldoc = ObjCreate('Microsoft.XMLDOM'), $ip If Not IsObj($xmldoc) Then Return -1 $xmldoc.async = False $xmldoc.load ('http://www.ippages.com/xml/') For $x In $xmldoc.documentElement.childNodes If $x.NodeName = "ip" Then $ip = $x.text ExitLoop EndIf Next $xmldoc = 0 Return $ip EndFunc Try this line it seems to work for me as the $xmldoc.load returns a -1 on sucess, 0 on failure: Dim $RetVal $RetVal = $xmldoc.load ('http://www.ippages.com/xml/') If $RetVal <> -1 Then Return ("No Connection") EndIF
cyanidemonkey Posted January 31, 2006 Author Posted January 31, 2006 thx billmez, that does the trick. My AutoIt Scripts.- AutoHost and Password Enabler for Delta Force 2 Demo.| Caffine for Winamp 2.9x and WRS 2.0 | mp3 directory cleaner | CRAP DJ | A:B:J Radio Automation Software | FFMPEG batch conversion automator
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