• 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: Why these errors?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Why these errors?


  • Subject: Re: Why these errors?
  • From: Christian Boyce <email@hidden>
  • Date: Sun, 09 Feb 2014 10:46:06 -0800


On Feb 9, 2014, at 6:18 AM, 2551 <2551phil@gmail.com> wrote:

I think it always help with AppleScript to keep in mind “who” (i.e., what) you are addressing with your commands.

When you write ‘tell application “Finder” ’ remember that the verb “tell” is not being addressed to the Finder. It’s being addressed to the parent script object in which that tell block resides. It has the form “the parent script object should tell the application “Finder” to…"

The commands inside the tell block, however, are being addressed to the Finder directly. So the command 

convert_the_file(the_file)

is equivalent to 

tell application “Finder to tell its handler convert_the_file(the_file)

Finder responds with an error because it has no such function/handler. Inserting the ‘my’ redirects the command up to the parent script object, which of course does know about the function as that’s where you’ve declared it. i.e., 

tell application “Finder to tell my handler convert_the_file(the_file)"

Yes, that helps a lot. So did Chris' pointer to the AppleScript Users Guide. Thanks, both of you.

I would have guessed that if the Finder doesn't know anything about the function/handler "convert_the_file" AppleScript would-- by default-- look "up a level" for convert_the_file's definition before erroring. To me, that would be great default behavior, and it seems obvious, but since it doesn't work that way I will use "my," same as everyone else does (since 1993). 

This has always been a weak part of my scripting game and I need to retrain my mind on it. Thanks again for the help.

c
 _______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users

This email sent to email@hidden

  • Follow-Ups:
    • Re: Why these errors?
      • From: 2551 <email@hidden>
    • Re: Why these errors?
      • From: 2551 <email@hidden>
References: 
 >Why these errors? (From: Christian Boyce <email@hidden>)
 >Re: Why these errors? (From: 2551 <email@hidden>)

  • Prev by Date: Re: Why these errors?
  • Next by Date: Re: Why these errors?
  • Previous by thread: Re: Why these errors?
  • Next by thread: Re: Why these errors?
  • Index(es):
    • Date
    • Thread