Retrieve the Reply Error From an Apple Event
· Dec 29, 03:49 PMThe REALbasic implementation of Apple events does not provide immediate access to the result code in the reply Apple event received in response to sending an event. But the property AppleEvent.ReplyPtr provides you with the information you need to retrieve it.
Here is a function extending the AppleEvent class that returns the reply error.
Function ReplyError(extends ae as AppleEvent) As Integer
#if targetMacOS
soft declare function AEGetParamPtr lib "Carbon.framework" (theAppleEvent as Integer, theAEKeyword as OSType, desiredType as OSType, actualType as Ptr, ByRef dataPtr as Integer, maximumSize as Integer, actualSize as Ptr) as Int16
const keyErrorNumber = "errn"
const typeWildCard = "****"
const sizeOfLong = 4
dim theError as Integer
dim OSErr as Int16 = AEGetParamPtr(ae.ReplyPtr, keyErrorNumber, typeWildCard, nil, theError, sizeOfLong, nil)
if OSErr = 0 then
return theError
else
return OSErr
end if
#endif
End Function
Commenting is closed for this article.