Jump to content

Search the Community

Showing results for tags 'seterr'.

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • General
    • Announcements and Site News
    • Administration
  • AutoIt v3
    • AutoIt Help and Support
    • AutoIt Technical Discussion
    • AutoIt Example Scripts
  • Scripting and Development
    • Developer General Discussion
    • Language Specific Discussion
  • IT Administration
    • Operating System Deployment
    • Windows Client
    • Windows Server
    • Office

Categories

  • AutoIt Team
    • Beta
    • MVP
  • AutoIt
    • Automation
    • Databases and web connections
    • Data compression
    • Encryption and hash
    • Games
    • GUI Additions
    • Hardware
    • Information gathering
    • Internet protocol suite
    • Maths
    • Media
    • PDF
    • Security
    • Social Media and other Website API
    • Windows
  • Scripting and Development
  • IT Administration
    • Operating System Deployment
    • Windows Client
    • Windows Server
    • Office

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


Member Title


Location


WWW


Interests

Found 1 result

  1. I'm new to COM error handling and trying to understand how to pass something back to the routine in which a COM exception/error occurred so the routine can act on it. The example program below shows how it can be done using a Global variable, however when I try and use SetError, which I thought was Global, it fails. Any hints on what I'm doing wrong would be appreciated as I'm stuck. ; #AutoIt3Wrapper_run_debug_mode=Y ;use this to debug in console window <--- LOOK ;https://www.autoitscript.com/forum/topic/196419-error-handling-help/ ;https://www.autoitscript.com/forum/topic/191401-com-error-handling-in-a-udf-best-practice/ Global $GlobalExceptionFlag = 0 ;init value Global $Test1Flag = 0 ;init value Global $oGlobalCOMException = ObjEvent("AutoIt.Error", "_GlobalCOMException") ;Global Exception ;Global test Pause("Before Global COM Exception" &@CRLF& "$GlobalExceptionFlag = " & $GlobalExceptionFlag) Global $oNonSense = ObjCreate("Nonsense.Application") ;trigger Global Exception Pause("After Global COM Exception" &@CRLF& "$GlobalExceptionFlag = " & $GlobalExceptionFlag) ;Local tests LocalTest_1() ;be careful with use of word Local LocalTest_2() ;be careful with use of word Local Exit ;----------- functions ;----------- Func _GlobalCOMException() $GlobalExceptionFlag = 1 ;set it Pause("IN: _GlobalCOMException()" &@CRLF& "$GlobalExceptionFlag = " & $GlobalExceptionFlag) EndFunc Func LocalTest_1() $oLocal1COMException = ObjEvent("AutoIt.Error", "_Local1COMException") ;Local Exception Pause("We are in LocalTest_1() before local exception" &@CRLF& "$Test1Flag = " & $Test1Flag) $oX1 = ObjCreate("MoreNonsense.Application") ;create exception Pause("We are in LocalTest_1() after local exception" &@CRLF& "$Test1Flag = " & $Test1Flag) EndFunc Func LocalTest_2() ;the problem with LocalTest_1 is that it requires a Global flag in the main program ;which is not a good idea if the functions we are providing are to be used by other ;people - they will not want to put in a Global however that is exactly what we need ;there is a solution as @error is Global for all programs ;so let's try it $oLocal2COMException = ObjEvent("AutoIt.Error", "_Local2COMException") ;Local Exception Pause("We are in LocalTest_2() before local exception" &@CRLF& "@error = " & @error) $oMoreNonSense = ObjCreate("MoreNonsense.Application");create more nonsense $iError = @error ;grab @error as we are getting @error = -2147221005 rather than 23. It makes no difference still get -2147221005 ;Pause("We are in LocalTest_2() after local exception, @error = " & @error) Pause("We are in LocalTest_2() after local exception" &@CRLF& "@error = " & $iError) EndFunc Func _Local1COMException() $Test1Flag = 1 ;set it Pause("IN: _Local1COMException()" &@CRLF& "$Test1Flag = " & $Test1Flag) EndFunc Func _Local2COMException() $Local1ExceptionFlag = 1 ;set it Pause("IN: _Local2COMException()" &@CRLF& "@error = " & @error) SetError(23) ;set it as last entry (Return SetError(23) makes no difference) EndFunc Func Pause($text="") MsgBox(262144, "DEBUG", $text) EndFunc
×
×
  • Create New...