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: Bug with coercions and keyAppHandledCoercion?



I'm not sure your application should be returning the same thing for each of these scripts.

What event is your application getting for the third example? Based on the parentheses I would expect it gets a request for all tasks as a list. An application must always return a list, even if it is empty, when it gets a request for 'every <something>. Only when there is a whose clause would you ever return an error if the result list is empty.

Note that the 'as list' is superfluous since a request for every item always returns a list. Doesn't hurt anything, just doesn't do anything either.

The way the script is written, the keyAppHandledCoercion parameter applies to the portion inside the parentheses, which means AppleScript is properly trying to perform a coercion to a task.

andy b


On Sep 1, 2006, at 7:30 AM, Stuart A. Malone wrote:


I've been tracking down an error that occurs when scripting my app. At first I assumed that it was a bug in my homegrown Carbon- based Apple Event handling code, but now I'm starting to think it might be a bug in Applescript...


Recently, I added code to set the keyAppHandledCoercion parameter in the reply to typeBoolean true when the requested type matched my class type. This was enough to make simple coercions like these work correctly:

	tell application "Life Balance"
		task 1 of document 1 as task
	end tell

	tell application "Life Balance"
		item 1 of every task of document 1 as task
	end tell

However, when I try something more complex:

	tell application "Life Balance"
		item 1 of (every task of document 1 as list) as task
	end tell

I get the error:

	Can't make <class Task> id "1797703789526674182" of
	document id 1 of application "Life Balance" into
	type <class Task>."

The reason I think this might be a bug in AppleScript is that in all three cases I'm returning exactly the same result from my core/ getd handler:

reply = 'aevt'\'ansr'{ '----':'obj '{ 'want':'Task', 'from':'obj '{ 'want':'docu', 'from':''null''(), 'form':'ID ', 'seld':1 }, 'form':'ID ', 'seld':"1797703789526674182" }, 'idas':1 }, err = 0

Is there a chance that Applescript is failing to notice that I've set the keyAppHandledCoercion parameter in this third case?


Best wishes,

--Stuart A. Malone
  Llamagraphics, Inc.
  Makers of Life Balance personal coaching software
  http://www.llamagraphics.com/


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


This email sent to email@hidden

_______________________________________________ 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: 
 >Bug with coercions and keyAppHandledCoercion? (From: "Stuart A. Malone" <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.