Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!

10.5: AppleScript 'path to me' function changed in 10.5 System 10.5
When using AppleScript, you sometimes want the running script (or AppleScript Application) to get the path to itself or a file in its resources folder. This is done by using the path to me command:
  set beep_sound to alias ((path to me as text) & 
  "Contents:Resources:Sounds:beep.mov") 
In 10.4, a problem I always found when writing one of these script/apps was that if you tried to test run them in Script Editor, the path to me function would return the path to Script Editor. There where ways around this, but it meant editing the script/app just to test. In 10.5, however, as long as you save the script/app first, then the path to me function will return the correct path to the script/app when tested in Script Editor.

As an example, this code...
 "display dialog ("The path to me is : " & return & (path to me))" 
...when run in 10.4's Script Editor from a saved script will return:
The path to me is : Macintosh HD:Applications:AppleScript:Script Editor.app:
In 10.5, though, it will display:
The path to me is : Macintosh HD:Users:username:path:to:foo.scpt
[robg adds: I can't easily test this on 10.4, but I can confirm the 10.5 behavior.]
    •    
  • Currently 2.78 / 5
  You rated: 2 / 5 (9 votes cast)
 
[23,645 views]  

10.5: AppleScript 'path to me' function changed in 10.5 | 2 comments | Create New Account
Click here to return to the '10.5: AppleScript 'path to me' function changed in 10.5' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
10.5: AppleScript 'path to me' function changed in 10.5
Authored by: gabester on Feb 28, '08 07:38:22AM

This is a great improvement... Previously, my workaround to this was to save my script as an applet and run the applet to test any "path to me" functionality. However, I usually wanted to have the discrete code separate from the applet, so I was constantly having to "save as" and frequently, during troubleshooting, I would update the code but forget to update the applet and then wonder why my coding bugs weren't fixed, sometimes hair-pullingly so for hours. g=



[ Reply to This | # ]
10.5: AppleScript 'path to me' function changed in 10.5
Authored by: john108 on Feb 28, '08 07:26:38PM

Or instead of Script Editor you could use (invest in) Script Debugger which allows you to change the behaviour with a preference setting.



[ Reply to This | # ]