Bresacon 1 Posted July 27 Share Posted July 27 (edited) If I declare a local variable inside a function and assign the return of ObjEvent("AutoIt.Error") to it, Au3Check.exe says "declared, but not used in func." But that's not true. I've used it. And there was a ton of COM errors, so it works and has done something. It's just an annoyance, everything works but... it is used in func. BTW, the COM error handling has to end (be disabled after the function ends), so it has to be local. I assign the variable to zero at the end, just in case. Edited July 27 by Bresacon Link to post Share on other sites
Developers Jos 2,690 Posted July 27 Developers Share Posted July 27 (edited) It is always helpful to post an snippet as reproducer. Is the message coming from AutoIt3 or au3check? Edited July 27 by Jos SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Link to post Share on other sites
Bresacon 1 Posted July 27 Author Share Posted July 27 23 minutes ago, Jos said: It is always helpful to post an snippet as reproducer. Is the message coming from AutoIt3 or au3check? Au3Check. I should've mention that I use this command line: Au3Check.exe -w 1 -w 2 -w 3 -w 4 -w 5 -w 6 -w 7 Ok. I've setup this. $iState = _CheckWindowsServiceState("Audiosrv") Msgbox(0, "", $iState) Func _CheckWindowsServiceState($sServiceName) Local $oObjectErrorCheck Local $objWMIService = ObjGet("winmgmts:\\" & @ComputerName & "\root\CIMV2") Local $colItems = $objWMIService.ExecQuery('SELECT * FROM Win32_Service WHERE Name = "' & $sServiceName & '"') $oObjectErrorCheck = ObjEvent("AutoIt.Error","_ObjectErrorInfo") If NOT IsObj($colItems) Then Return SetError(1,0,0) If NOT $colItems.count Then Return SetError(2,0,0) For $oItem In $colItems If $oItem.StartMod = "Disabled" then Return 0 If $oItem.StartMode = "Disabled" then Return 0 If $oItem.State = "Running" then Return 1 If $oItem.State = "Stopped" then Return 2 If $oItem.State = "Unknown" then Return 3 Next EndFunc Func _ObjectErrorInfo($oMyError) Msgbox(0,"AutoItCOM Test","We intercepted a COM Error !" & @CRLF & @CRLF & _ "err.description is: " & @TAB & $oMyError.description & @CRLF & _ "err.windescription:" & @TAB & $oMyError.windescription & @CRLF & _ "err.number is: " & @TAB & hex($oMyError.number,8) & @CRLF & _ "err.lastdllerror is: " & @TAB & $oMyError.lastdllerror & @CRLF & _ "err.scriptline is: " & @TAB & $oMyError.scriptline & @CRLF & _ "err.source is: " & @TAB & $oMyError.source & @CRLF & _ "err.helpfile is: " & @TAB & $oMyError.helpfile & @CRLF & _ "err.helpcontext is: " & @TAB & $oMyError.helpcontext _ ) Endfunc The error in the "StartMod" field is what triggers the _ObjectErrorInfo function. Sorry if I said something silly. I'm learning. Link to post Share on other sites
Developers Solution Jos 2,690 Posted July 27 Developers Solution Share Posted July 27 The warning is correct as it only is use on the left hand side of an = sign. So the code isn't wrong per se but the variable is nowhere used ...hence the warning. SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Link to post Share on other sites
Bresacon 1 Posted July 27 Author Share Posted July 27 So there's no fix for me to do? I'll let it be then. Link to post Share on other sites
Danp2 1,277 Posted July 27 Share Posted July 27 Search the help file for the term #forceref. Bresacon 1 WebDriver UDF [GH&S] Latest version Wiki FAQs Link to post Share on other sites
ripdad 103 Posted July 27 Share Posted July 27 (edited) 1. ObjEvent() needs to be before the line ObjGet(). 2. Replace $oObjectErrorCheck with $oMyError. 3. StartMod is not a valid class property. Just remove that line and you should be good to go. Edited July 28 by ripdad more scrutiny... "The mediocre teacher tells. The Good teacher explains. The superior teacher demonstrates. The great teacher inspires." -William Arthur Ward Link to post Share on other sites
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