• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: What's going on here?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: What's going on here?


  • Subject: Re: What's going on here?
  • From: Christopher Nebel <email@hidden>
  • Date: Thu, 29 Jun 2006 11:49:44 -0700

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:

This email sent to email@hidden
  • Follow-Ups:
    • Re: What's going on here?
      • From: Adam Bell <email@hidden>
References: 
 >What's going on here? (From: Adam Bell <email@hidden>)

  • Prev by Date: Re: What's going on here?
  • Next by Date: Re: What's going on here?
  • Previous by thread: Re: What's going on here?
  • Next by thread: Re: What's going on here?
  • Index(es):
    • Date
    • Thread