At 3:22 AM +0100 2/3/01, Sjoerd Op 't Land wrote:
>OK, this worked. I'm now working on a library (in the Starter Kit, so I have
>to keep it short) for setting and getting file attributes. For finishing I
>need the AppleScript for setting file's attributes. I tried many things like
>this:
> set name of alias "HD Sjoerd:Desktop Folder:testfile" to "ttt"
> set name of file "HD Sjoerd:Desktop Folder:testfile" to "ttt"
>
>But I didn't succeed. The first one gave me: "Stack overflow." What does
>that mean? And the second (translated) ""ttt" cannot be given to the name of
>file "HD Sjoerd:Desktop Folder:testfile"".
Try this:
put "HD Sjoerd:Desktop Folder:testfile" into tPath
put "ttt" into tNewName
put "tell application " & quote & "Finder" & quote & " to set name of file " \
& quote & tPath & quote & "to" & quote & tNewName & quote into tScript
send tScript to program "Finder" with "sysodsct"
However, I think you may be reaching some practical limits for this
"sysodsct" approach.
The file information example I used before used AppleScript's
built-in commands. But for any serious file management stuff, you'll
need to use the Finder's own dictionary of commands and objects. But
if you check the result of the above "send" command, you'll probably
find it returns an error (even though it carries out the task). I get
errors returned on any scripts sent to the Finder that include <tell
application "Finder"> as part of the script. I guess this is because
you're asking the Finder to send appleEvents to itself, and it
doesn't like this. (Just guessing, though.)
Therefore, when you need to get the result from a Finder command,
you're in trouble, because all you get is an error.
A workaround is to send the script to a different running application
that handles appleEvents, but generally the Finder is the only
application that can be guaranteed to be running. I discovered on my
Mac that there is a process called "Folder Actions" that is always
running, and sending the script to this process works.
E.g.
send tScript to program "Folder Actions" with "sysodsct"
But I've no idea whether "Folder Actions" runs on all Macs as a
faceless process. If you save an empty AppleScript as an applet (with
"Stay Open" checked), and then run that applet, you can then send
scripts to it.
E.g.
send tScript to program "My Dead Applet" with "sysodsct"
However, if you're going to need another running application to which
you can send scripts, it would probably be better to compile the
scripts as an AppleScript applet to start with. And it would probably
be faster too.
But all in all, I think the Externals Collection offers the best
solutions for most situations.
Cheers
Dave Cragg
Archives: http://www.mail-archive.com/[email protected]/
Info: http://www.xworlds.com/metacard/mailinglist.htm
Please send bug reports to <[EMAIL PROTECTED]>, not this list.