Clarification: AppleScript in Navigation Bar

In order to run AppleScript from Xojo, you drag the completed AppleScript to the Navigation bar. Then you can run the AppleScript by calling it using its name in your code. The icon that you see in the Navigation bar has a little curved arrow at the corner similar to the “alias” icon which suggests to me that it has a link back to the AppleScript in the Finder.

Indeed, if I modify the AppleScript and Save it, its new functionality is invoked when I call it from the Xojo app. The little curved arrow and the behavior suggested in my mind that the AppleScript in the Navigation bar was no more than a link or a reference to the file in the Finder.

But as best I can tell, it is more than that. If I delete the file from the Finder, Xojo can continue to call the AppleScript and it works just fine in my limited experience. So this suggests to me that Xojo has a complete copy of the AppleScript and is not dependent on the existence of the original file at all.

Am I understanding this correctly?

  1. Xojo maintains a complete copy of the AppleScript that was dragged to it from the Finder and does not depend on the continuing existence of the Finder version of the file.
  2. While Xojo has a complete copy, if you modify that file in the Finder and save the modification, Xojo is “aware” of this and when you rerun the Xojo app in the IDE or rebuild it, it will use the updated version.

If these two things are true, that makes my life easier because if I give the app to somebody I do not have to worry about a separate AppleScript file.

No, you need to keep that file.

What you are experiencing is that the IDE keeps a copy in memory while the project is open. If you were to close the project and reopen it, the IDE will need it to load it again.

1 Like

Is there any trick to actually save the AppleScript code in the project. (as you can save text in a constant) so that the user would not actually have to own and manage this separate file?

You may want to check classes like AppleScriptMBS or NSAppleScriptMBS in MBS Xojo Plugins, where you can compile and execute code at runtime.

Otherwise copy your saved script into the project folder and drag it from there into the project. Xojo should then include it with a build.

1 Like

By that do you mean that it is baked into the compiled built app and the customer would not have to deal with a separate file?

Yes

1 Like