Re: Setting File & Creator Type access error
Re: Setting File & Creator Type access error
- Subject: Re: Setting File & Creator Type access error
- From: Matt Neuburg <email@hidden>
- Date: Wed, 01 Jul 2009 12:26:57 -0700
- Thread-topic: Setting File & Creator Type access error
On Wed, 01 Jul 2009 11:37:11 -0700, "Stockly, Ed" <email@hidden>
said:
>> tell application "Finder"
>> set my_file to choose file
>> set file type of my_file to "THIS "
>> set creator type of my_file to "that"
>> end tell
>
>> Nothing serious, but why does it take four lines of code to do what should be
>done in one?
>
>FWIW, in AppleScript, breaking a command into multiple lines is not
>considered a problem. It adds no overhead to execution time and is often (as
>in this case) more reliable than combining multiple commands into a single
>line.
Right, that's sort of the answer I was going to give. Basically, this
syntax:
set {a, b} to {1, 2}
...although extraordinarily convenient and implemented as part of the
AppleScript language's own internal syntax, is not implemented by every
scriptable application for setting e.g. property values. But since even if
it *is* implemented you are sending separate Apple events for each property
value being set, there is absolutely no penalty for just writing it out and
setting them one at a time.
For more about this, see p. 206 of my book ("Assignment of Multiple
Attributes"). I give an example there that *does* work in the Finder.
As for "why it takes four lines of code to do what should be done in one",
it's because, well, AppleScript is not Ruby. :) m.
--
matt neuburg, phd = email@hidden, <http://www.tidbits.com/matt/>
A fool + a tool + an autorelease pool = cool!
AppleScript: the Definitive Guide - Second Edition!
http://www.tidbits.com/matt/default.html#applescriptthings
_______________________________________________
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