Re: Can a script change its own name?
Re: Can a script change its own name?
- Subject: Re: Can a script change its own name?
- From: Jan Pieter Kunst <email@hidden>
- Date: Sun, 27 May 2001 15:39:02 +0200
Bill Briggs (email@hidden) schreef op 27-05-2001 15:08 :
>
At 2:07 PM +0200 27/05/01, Jan Pieter Kunst wrote:
>
> I suspect that it is not possible to have the script change its own
>
> name while it is running.
>
>
No, you can do it. Did you save it as an application, or try to run
>
it from the editor you are using? Here's some quick and dirty code
>
that works fine for me when saved as an application.
>
>
- web
>
>
property myName : "on"
>
tell application "Finder"
>
set x to path to me
>
if name of x is "on" then
>
set name of x to "off"
>
else if name of x is "off" then
>
set name of x to "on"
>
end if
>
end tell
Indeed, that works. I experimented with "me" in the Script Editor first, but
I noticed that it seemed to refer to the Script Editor application instead
of the script. I didn't realize that the referent of "me" would probably
change if the script was saved as an application.
I also didn't realize that I had to use the name of a path instead of the
name of a file.
Thanks!
Jan Pieter.-