Why does Applescript run in Script Editor, but error when saved as Application?

Here's another thought although I haven't checked. One thing that can cause problems is the command "get". In general when you run a command like "name of me" the command get is implied so you're really running "get name of me".

The problem is that the implied "get" is not always the case. So sometimes you have to explicitly say "get". Whenever I have a problem like yours the first thing I try is to add "get" to the command... it's become habit because you just never know.

Note that you can always use the word get and never have that issue. As such, try changing your command to "set my_name to (get name of me)". I'd be interested to know if that fixes your 10.5 problem.

Also note that a name is already a string so there's no need to coerce the result to a string.

Here's another thought although I haven't checked. One thing that can cause problems is the command "get". In general when you run a command like "name of me" the command get is implied so you're really running "get name of me".

The problem is that the implied "get" is not always the case. So sometimes you have to explicitly say "get". Whenever I have a problem like yours the first thing I try is to add "get" to the command... it's become habit because you just never know.

Note that you can always use the word get and never have that issue. As such, try changing your command to "set my_name to (get name of me)". I'd be interested to know if that fixes your 10.5 problem.

Also note that a name is already a string so there's no need to coerce the result to a string. EDIT: I looked through some of my older scripts. I used the following code to get the name.In my notes I have these comments... -- this will get the name of the application or script without any file extension -- it is done using the path because when a script is run from the script menu, and you write set myName to name of me, then the result is "applescript runner" instead of the actual name -- also it assures that you're getting the name as it appears in the Finder because sometimes the system events process name is different than the Finder name on getMyName() set myPath to path to me as text if myPath ends with ":" then set n to -2 else set n to -1 end if set AppleScript's text item delimiters to ":" set myName to text item n of myPath if (myName contains ".

") then set AppleScript's text item delimiters to ". " set myName to text 1 thru text item -2 of myName end if set AppleScript's text item delimiters to "" return myName end getMyName.

I just tried it and the command get name of me merely returns the error message "Can't get name". I think this goes back to my theory that an Applescript application is an atypical application. – Philip Regan Jul 29 '10 at 13:09 Thanks for checking that Philip.

I edited my answer so check that out for another solution. – regulus6633 Jul 30 '10 at 8:01 I appreciate both of your answers, and the help. My solution ended up closely following the code you have, using the path instead of simply "name of", which for reasons still unknown, returns different things in Leopard and Snow Leopard.Thanks.

– mlusby Jul 30 '10 at 14:21.

An Applescript application isn't an "application" in the truest sense of the word. A lot of contexts change, like "get path to me" will be different when run as a script or as an application, because they are still good ol' wonky Applescript as opposed to a Carbon or Cocoa-based application. Running similar code against the Finder... tell application "Finder" set my_name to name as string display dialog "Finder: " & my_name end tell ...behaves as expected because the Finder is a Carbon/Cocoa-based application.

I don't have a real answer other than to say it sounds like there was a change made to the OS relative to the Applescript framework in 10.6 that makes the call to "me" behave more as expected. I would recommend reading the section in the Applescript guide about the me and it keywords to gain more insight into how me works.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions