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: What's going on here?



Thank you. BTW, both Script Editor and Script Debugger exhibit this behavior, presumably because both are native Cocoa.

Adam

At 11:49 AM -0700 6/29/06, Christopher Nebel wrote:
On Jun 29, 2006, at 9:28 AM, Adam Bell wrote:

At the heart of a more complex script failure, I discovered this:

{count 1234, count "1234"} --> {0, 4} in an editor, but
fails with "1234 doesn't understand the count message" if compiled.

Why does this work from the editors, but not when compiled?

Because (1) messages that AppleScript can't handle are delegated to the application, and (2) Cocoa Scripting is being over-enthusiastic about handling "count". (Or AppleScript is being over-enthusiastic about delegating. It's a matter of perspective.) Script Editor, being a scriptable Cocoa application, has the Cocoa Scripting machinery, but an applet isn't and doesn't, hence the error.


(How do I know you meant "Script Editor"? Because you don't get the same behavior in all editors. Smile 3 says "Expected a reference.")

By the way, "count" doesn't mean quite what you think it does. "Count" is actually defined as "count <container> [each <class>]", where the "each" parameter defaults to "item". AppleScript cleverly [1] transmogrifies things like "count every x of y" into "count y each x", but if you don't have something like that -- say you're giving it a plain value, like a string -- you're effectively saying "count <thing> each item". Strings do indeed have "items" -- they're synonymous with characters (not text items!) -- but numbers do not.


--Chris Nebel AppleScript Engineering

[1] For some definition of "cleverly". I wish they hadn't done that, because it makes some constructions mean un-obvious things, and I'm pretty sure it's not necessary.
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Applescript-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/applescript-users/email@hidden


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

This email sent to email@hidden
References: 
 >What's going on here? (From: Adam Bell <email@hidden>)
 >Re: What's going on here? (From: Christopher Nebel <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.