Important: The information in this document is obsolete and should not be used for new development.
Adding Parameters to an Apple Event
You can use theAEPutParamPtr
orAEPutParamDesc
function to add parameters to an Apple event. When you use either of these functions, the Apple Event Manager adds the specified parameter to the Apple event.Use the
AEPutParamPtr
function when you want to add data specified in a buffer as the parameter of an Apple event. You specify the Apple event, the keyword of the parameter to add, the descriptor type, a buffer that contains the data, and the size of this buffer as parameters to theAEPutParamPtr
function. TheAEPutParamPtr
function adds the data to the Apple event as a parameter with the specified keyword.For example, this code adds a parameter to the Multiply event using the
AEPutParamPtr
function:
CONST keyOperand1 = 'OPN1'; VAR number1: LongInt; theAppleEvent: AppleEvent; myErr: OSErr; number1 := 10; myErr := AEPutParamPtr(theAppleEvent, keyOperand1, typeLongInteger, @number1, SizeOf(number1));In this example, the Apple Event Manager adds the parameter containing the first number to the specified Apple event.Use the
AEPutParamDesc
function to add a descriptor record to an Apple event. The descriptor record you specify must already exist. To create or get a descriptor record, you can use theAECreateDesc
,AEDuplicateDesc
, and other Apple Event Manager functions that return a descriptor record.When you create a descriptor record using the
AECreateDesc
function, you specify the descriptor type, a buffer that contains the data, and the size of this buffer as parameters. TheAECreateDesc
function returns the descriptor record that describes the data.This example creates a descriptor record for the second parameter of the Multiply event:
VAR number2: LongInt; multParam2Desc: AEDesc; myErr: OSErr; number2 := 8; myErr := AECreateDesc(typeLongInteger, @number2, SizeOf(number2), multParam2Desc);In this example, theAECreateDesc
function creates a descriptor record with thetypeLongInteger
descriptor type and the data identified in thenumber2
variable.Once you have created a descriptor record, you can use
AEPutParamDesc
to add the data to an Apple event parameter. You specify the Apple event to add the parameter to, the keyword of the parameter, and the descriptor record of the parameter as parameters to theAEPutParamDesc
function.This example adds a second parameter to the Multiply event using the
AEPutParamDesc
function:
CONST keyOperand2 = 'OPN2'; myErr := AEPutParamDesc(theAppleEvent, keyOperand2, multParam2Desc);This example adds thekeyOperand2
keyword and the descriptor record created in the previous example as the second parameter to the specified Apple event.You can also create a descriptor record without using Apple Event Manager routines. For example, this example generates an alias descriptor record from an existing alias handle:
WITH myAliasDesc DO BEGIN descriptorType := typeAlias; dataHandle := myAliasHandle; END;Whatever method you use to create a descriptor record, you can add it to an Apple event parameter by usingAEPutParamDesc
.After adding parameters to an Apple event, you can send the Apple event using the
AESend
function. See "Sending an Apple Event," which begins on page 5-13, for information about using this function.