Carbon


AESend

Header: AEInteraction.h Carbon status: Supported

Sends the specified Apple event.

OSErr AESend (
    const AppleEvent *theAppleEvent, 
    AppleEvent *reply, 
    AESendMode sendMode, 
    AESendPriority sendPriority, 
    SInt32 timeOutInTicks, 
    AEIdleUPP idleProc, 
    AEFilterUPP filterProc
);
Parameter descriptions
theAppleEvent

A pointer to the Apple event to send.

reply

A pointer to a reply Apple event. On return, contains the reply Apple event from the server application, if you specified the kAEWaitReply flag in the sendMode parameter. If you specify the kAEQueueReply flag in the sendMode parameter, you receive the reply Apple event in your event queue. If you specify kAENoReply flag, the reply Apple event is a null descriptor record. If you specify kAEWaitReply in the sendMode parameter, your application is responsible for using the AEDisposeDesc function to dispose of the descriptor record returned in the reply parameter. These constants are described in “Preferences Constants for the AESend Function”

sendMode

Specifies various options for how the server application should handle the Apple event. To obtain a value for this parameter, you add together constants to set bits that specify the reply mode, the interaction level, the application switch mode, the reconnection mode, and the return receipt mode. The constants are described in “Preferences Constants for the AESend Function”.

sendPriority

A value that specifies the priority for processing the Apple event. You can specify normal or high priority, using the constants described in “Priority Constants for the AESend Function”.

timeOutInTicks

If the reply mode specified in the sendMode parameter is kAEWaitReply, or if a return receipt is requested, this parameter specifies the length of time (in ticks) that the client application is willing to wait for the reply or return receipt from the server application before timing out. Most applications should use the kAEDefaultTimeout constant, which tells the Apple Event Manager to provide an appropriate timeout duration. If the value of this parameter is kNoTimeOut, the Apple event never times out. These constants are described in “Timeout Constants”.

idleProc

A universal procedure pointer to a function that handles events (such as update, operating-system, activate, and null events) that your application receives while waiting for a reply. Your idle function can also perform other tasks (such as displaying a wristwatch or spinning beach ball cursor) while waiting for a reply or a return receipt.

If your application specifies the kAEWaitReply flag in the sendMode parameter then it must provide an idle function—otherwise, you can pass a value of NULL for this parameter. For more information on the idle function, see AEIdleProcPtr.

filterProc

A universal procedure pointer to a function that determines which incoming Apple events should be received while the handler waits for a reply or a return receipt. If your application doesn’t need to filter Apple events, you can pass a value of NULL for this parameter. If you do so, no application-oriented Apple events are processed while waiting. For more information on the filter function, see AEFilterProcPtr.

function result

A result code. The AESend function returns noErr if the Event Manager successfully sends the Apple event—this value does not indicate that the Apple event was handled successfully. If the handler returns a result code other than noErr, and if the client is waiting for a reply, AESend returns the result code in the keyErrorNumber parameter of the reply Apple event.

DISCUSSION

You typically create an Apple event to send with the AECreateAppleEvent function and add information to it with the functions described in “Adding Data and Descriptor Records to an AE Record or an Apple Event Record” and “Adding Parameters and Attributes to an Apple Event”.

If the Apple Event Manager cannot find a handler for the Apple event in the server application’s dispatch table or in the system dispatch table, it returns the result code errAEEventNotHandled to the server application (as the result of the AEProcessAppleEvent function). If the client application is waiting for a reply, the Apple Event Manager also returns this result code to the client in the keyErrorNumber parameter of the reply event.

You use the sendMode parameter to specify how the server should handle the Apple event.“Preferences Constants for the AESend Function” provides a complete description of the constants you use with this parameter.

VERSION NOTES

A Carbon application should not install a handler in a system dispatch table with the goal that the handler will get called when other applications receive events—this won’t necessarily work. See “Apple Event Dispatching” (to be supplied later) for more information.

AVAILABILITY

Supported in Carbon. Available in Carbon 1.0.2 and later when running Mac OS 8.1 or later.


© 2000 Apple Computer, Inc. (Last Updated 6/30/2000)