Re: Saving an AppleScript that targets my own application
Re: Saving an AppleScript that targets my own application
- Subject: Re: Saving an AppleScript that targets my own application
- From: Matt Neuburg <email@hidden>
- Date: Fri, 13 Jan 2006 07:51:40 -0800
- Thread-topic: Saving an AppleScript that targets my own application
On Wed, 11 Jan 2006 21:44:37 -0600, Derrick Bass <email@hidden>
said:
>On Jan 8, 2006, at 9:33 AM, Daniel Jalkut wrote:
>
>> Hi Derrick - we need to get to the bottom of this problem in your
>> particular case. Suffice to say that this is not a problem across
>> the board.
>>
>Sorry for the delay; I was having a off-list discussion with Nathan
>Day (author of NDAppleScriptObject). We managed to make some
>progress, but ultimately he could not reproduce my problem. I've been
>able to reproduce it on two accounts on my computer (running 10.4.2)
>as well as another computer running 10.3.9; I also got misbehavior of
>a different sort on another 10.3.9 box.
>
>I managed to create a very simple test app that demonstrates the
>problem (at least for me):
><http://www.tapir.caltech.edu/~derrick/ASsave.zip>
>
>> I use NDApplecript in FastScripts, where I run all manner of
>> scripts including scripts that are targeting FastScripts itself.
>>
>> That being said, I don't *compile* the scripts in FastScripts - is
>> that what you're doing with your example script? As a quick test,
>> what happens if you paste and save the script from Script Editor,
>> and then load it as a compiled script from disk in your application?
>>
>My app doesn't load or run AppleScripts; what's happening is that
>when users find a combination of options useful, they can select
>"save as script". That is supposed to save a compiled AppleScript
>that will call the program with the same set of options. As per
>Nathan's suggestion, I added a creator code to my app and used the
>NDComponentInstance function setDefaultTargetAsCreator. This helps:
>the script is correctly interpreted if the application is left
>running. But it still won't work if the program is quit.
>
>In the sample app above, the script is just
>tell application "ASsave"
> do it
>end tell
>
>What I want to do is save this script in such a way that *another*
>program can load and run it (iTunes, to be specific).
>
>Anyway, if you run the sample app I linked to, clicking the "Save
>Script" button compiles and saves this script on the Desktop.
>
>Now if I leave ASsave open and open the script in Script Editor, it
>looks fine and it runs fine. Now I close the script and then quit
>ASsave. Now opening the script again, I'm presented with a dialog
>asking me "Where is ?". I'm assuming that somehow the name of ASsave
>is not getting stored in the script. (On a second 10.3.9 box, Script
>Editor simply froze; I left it for a few hours, but it never came
>back; Activity Monitor showed it was searching the disk). If I select
>ASsave from the list, then the script once again looks fine and
>functions properly. Now I close it again. Forever after, if I open
>the script with ASsave not running, it instead reads
>tell application "Script Editor"
> «event ASs doit»
>end tell
>
>which of course doesn't work.
>
>> Also, is there anything funky about your application, like you
>> forgot to give it a Bundle ID or something?
>>
>
>No, it has a bundle id. And, as I mentioned, I added a creator code too.
Derrick - It works fine here too. I did notice, though, that the encoding is
incorrectly set for your sdef file, and also you are using a custom
application class without the sdef hooking this back up to the built-in
"capp" class properly, which does kind of worry me. (That is, it needs to
inherit from NSCoreSuite.NSApplication.) I am inclined to wonder whether the
problem might be connected to this.
I suspect that the reason the problem does not emerge on my machine is that
I'm running Tiger. You are probably developing on Panther. I do notice that
you are building a Panther-style scriptable app, with
scriptSuite/scriptTerminology pairs (and no 'aete'). This means that your
app must launch in order for the saved script to open. I would suggest that
either you make this app Tiger-only so that it can be scriptable directly
from the sdef, or that you build an 'aete' resource as part of the build
process so that the dictionary is not dynamic, and see if that makes a
difference.
I also agree with Daniel's suggestion that this might simply be an odd
problem on your own machine - I sometimes find that I have to restart my
computer during development of a scriptable app, in order to get changes to
the dictionary to "take".
Finally, the problem you're having would be better addressed on the
AppleScript-Implementors list. m.
--
matt neuburg, phd = email@hidden, <http://www.tidbits.com/matt/>
A fool + a tool + an autorelease pool = cool!
AppleScript: the Definitive Guide
<http://www.amazon.com/exec/obidos/ASIN/0596005571/somethingsbymatt>
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden