Modify

Opened 13 years ago

Closed 12 years ago

#2410 closed Feature Request (Fixed)

Obj/COM Reference - PROPOSAL

Reported by: mlipok Owned by: J-Paul Mesnage
Milestone: 3.3.9.21 Component: Documentation
Version: Severity: None
Keywords: Cc:

Description

in "Language Reference" in "Obj/COM Reference"

Please consider adding link to this function

"The main line in this script is: $EventObject=ObjEvent($oIE,"IEEvent_",...)."

"Error handling is implemented in the same way as a normal COM Event, using ObjEvent() and a user defined"

"This is the name to be used in an ObjCreate, ObjGet or ObjEvent function."

in "COM Error Handling" section

please consider to change an example:
now is:

Global $iEventError = 0 ; to be checked to know if com error occurs. Must be reset after handling.

$oMyError = ObjEvent("AutoIt.Error", "ErrFunc") ; Install a custom error handler

; Perform a deliberate failure (the object doesn't exist)
$oIE = ObjCreate("InternetExplorer.Application")
$oIE.visible = 1
$oIE.bogus
If $iEventError Then
    MsgBox(0, "", "There was an error on the previous line.")
    $iEventError = 0 ; Reset after displaying a COM Error occurred
EndIf
Exit

; This is a custom error handler
Func ErrFunc()
    $HexNumber = Hex($oMyError.number, 8)
    MsgBox(0, "", "We intercepted a COM Error !" & @CRLF & _
            "Number is: " & $HexNumber & @CRLF & _
            "WinDescription is: " & $oMyError.windescription)
    $iEventError = 1 ; Use to check when a COM Error occurs
EndFunc   ;==>ErrFunc

Proposal:

#include <MsgBoxConstants.au3>
Global $iEventError = 0 ; to be checked to know if com error occurs. Must be reset after handling.

$oMyError = ObjEvent("AutoIt.Error", "ErrFunc") ; Install a custom error handler

; Perform a deliberate failure (the object doesn't exist)
$oIE = ObjCreate("InternetExplorer.Application")
$oIE.visible = 1
$oIE.bogus
If $iEventError Then
    MsgBox($MB_OK, "", "There was an error on the previous line.")
    $iEventError = 0 ; Reset after displaying a COM Error occurred
EndIf
Exit

; This is a custom error handler
Func ErrFunc()
    $HexNumber = Hex($oMyError.number, 8)
    MsgBox($MB_OK, "", "We intercepted a COM Error !" & @CRLF & _
            "Number is: " & $HexNumber & @CRLF & _
            "WinDescription is: " & $oMyError.windescription & @CRLF & _
            "source is: " & $oMyError.source & @CRLF & _
            "description is: " & $oMyError.description & @CRLF & _
            "helpfile is: " & $oMyError.helpfile & @CRLF & _
            "helpcontext is: " & $oMyError.helpcontext & @CRLF & _
            "lastdllerror is: " & $oMyError.lastdllerror & @CRLF & _
            "scriptline is: " & $oMyError.scriptline & @CRLF & _
			"" )
    $iEventError = 1 ; Use to check when a COM Error occurs
EndFunc   ;==>ErrFunc

Attachments (0)

Change History (3)

comment:1 by TicketCleanup, 13 years ago

Version: 3.3.9.18

Automatic ticket cleanup.

comment:2 by mlipok, 13 years ago

Explanation for example:
I think that the examples are often used code fragments in programs that are written for all developers, but especially for novices.
I think it would be good if the example was quite complementary, as I suggested in this case.

comment:3 by J-Paul Mesnage, 12 years ago

Milestone: 3.3.9.21
Owner: set to J-Paul Mesnage
Resolution: Fixed
Status: newclosed

Fixed by revision [8985] in version: 3.3.9.21

Modify Ticket

Action
as closed The owner will remain J-Paul Mesnage.

Add Comment


E-mail address and name can be saved in the Preferences .
 
Note: See TracTickets for help on using tickets.