Hi there
I’ve been using Xcode 2.4 on Tiger 10.4.7 to create an AppleScript droplet that uses Satimage’s XMLLib 2.8.7. It all works fine (runs etc.) in my user account that has the .osax in /Library/ScriptingAdditions. However, I’ve made the build include a copy of the .osax in the Contents/Resources/Scripting Additions folder of the droplet .app - for those users that don’t have the osax (because I don’t want them to have to install it themselves). Attempting to run this in another user account that doesn’t have a copy of the .osax in its Library/ScriptingAdditions was giving me x doesn’t understand the <> message (-1708) error.
I was going to ask for assistance in what was going on, but as I was getting exact details of the error message, I noticed that it wasn’t my script that was reporting the error, but actually an application I was telling something to. This put me on to the solution, which I thought I ought to share…
I believe that what was happening was something like the following - in my script I had a structure like:
tell application “X”
:
set something to XMLOpen filename as alias
:
end tell
This works fine in my account (when developing) because the osax is in your Library/ScriptingAdditions folder and, I believe, the additions are effectively global and therefore application “X” as well as my script can find them. However, when you bundle the osax into the app’s Contents/Resources/Scripting Additions (note the space) - it’s effectively private to your app and application “X” can no longer access the functionality/messages etc. So, by changing my code to read more like:
set something to XMLOpen filename as alias
tell application “X”
:
end tell
It now works fine…
This is the second time that a rather too wide ‘tell’ block has caused me grief (the other was in calling my own events, when I discovered the ‘my’ keyword). Therefore, to all other AppleScripting newbies, bear in mind that that tell block isn’t just a convenient dereferencing syntax, it also changes the scripts operating context pretty significantly!