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

Why these errors?


  • Subject: Why these errors?
  • From: Christian Boyce <email@hidden>
  • Date: Fri, 07 Feb 2014 17:56:57 -0800

I have this little practice script:

tell application "Finder"
set the_selection to the selection
repeat with I from 1 to count of the_selection
set the_file to item I of the_selection
my convert_the_file(the_file)
end repeat
end tell

on convert_the_file(some_file)
display dialog (name of some_file as string)
end convert_the_file

Easy stuff, and it works. But, if I leave off the "my" so that the calling line says…

convert_the_file(the_file)

I get an error:

error "Finder got an error: Can’t continue convert_the_file." number -1708

When did "my" become the key for a handler like this? And what's the point of requiring it? It's not as if there is some other "convert_the_file" handler that the script might get confused about-- or is there?

***

I have a second question. If the display dialog line doesn't have the "as string" at the end, I get this error:

error "Finder got an error: Can’t make name of document file \"IMG_4420.jpg\" of folder \"Desktop\" of folder \"cboyce\" of folder \"Users\" of startup disk into type string." number -1700 from name of document file "IMG_4420.jpg" of folder "Desktop" of folder "cboyce" of folder "Users" of startup disk to string

It seems funny that the error says "Finder got an error: Can't make name of document file… to string" when I can turn the name of the document into a string just by putting "as string" at the end. If I can do it that way, why can't the Finder do it? Or is something else doing the work-- that is, not the Finder? But still-- why not?

The name of the file is already class "text" which I verified by changing the handler to look like this:

on convert_the_file(some_file)
set x to the name of some_file
log class of x
display dialog (x)
end convert_the_file

In this case the script runs fine, and the log shows "(*text*)" for the class of x. 

Why do I have to coerce "name of some_file" to a string if it's inside the display dialog line, but I don't have to do that if I get the "name of some_file" and pass it to the display dialog command? I'm trying to make my stuff more efficient and I'd rather do it all in one line. 

Thanks for your help on this.

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: Axel Luttgens <email@hidden>
    • Re: Why these errors?
      • From: Shane Stanley <email@hidden>
  • Prev by Date: Re: Mavericks, Calendar, Applescript alarms
  • Next by Date: Re: Why these errors?
  • Previous by thread: Re: Mavericks, Calendar, Applescript alarms
  • Next by thread: Re: Why these errors?
  • Index(es):
    • Date
    • Thread