Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Extract text out of NSAppleEventDescriptor



On 2007-03-11, at 02:45, Ivan C Myrvold wrote:

Folks agree that you're not getting a valid input. If you have no options to change the input, then the easiest thing is to get the raw bytes and take a chance on something similar to CFStringCreateFromExternalRepresentation() or CFStringCreateWithFormat() since we've seen the bytes are big endian. CFStringCreateWithFormat() presumes a lot in terms of encoding while other raw byte constructors make you guess.

So (c99):

This is unknown territory for me. I tried to obtain the AEDesc desc, to plug it into your routine below:

OSStatus err = AESendMessage( theAppleEventPtr, &reply, kAEWaitReply, kAEDefaultTimeout );

Hi Ivan,

From the call above, for a simple reply that you expect to return a text value (or even numbers), it would be:

err = AEGetParamDesc( &reply, keyDirectObject, typeUnicodeText, &desc );

IOW, AEGetParamDesc() will attempt to coerce the direct object to a type you desire.


For an unknown reply type, then you can proceed with:

err = AEGetParamDesc( &reply, keyDirectObject, typeWildCard, &desc );

This will return the actual type of the the direct parameter. You can then look at UTCreateStringForOSType( desc.descriptorType ) to see the real type and branch on it to handle various data types.


Philip Aker
echo email@hidden@nl | tr a-z@. p-za-o.@



 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Applescript-implementors mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/applescript-implementors/email@hidden

This email sent to email@hidden

References: 
 >Extract text out of NSAppleEventDescriptor (From: Ivan C Myrvold <email@hidden>)
 >Re: Extract text out of NSAppleEventDescriptor (From: Ivan C Myrvold <email@hidden>)
 >Re: Extract text out of NSAppleEventDescriptor (From: Philip Aker <email@hidden>)
 >Re: Extract text out of NSAppleEventDescriptor (From: Ivan C Myrvold <email@hidden>)
 >Re: Extract text out of NSAppleEventDescriptor (From: Philip Aker <email@hidden>)
 >Re: Extract text out of NSAppleEventDescriptor (From: Ivan C Myrvold <email@hidden>)



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.