Back in the project window, you should now see, in the
ScriptableDocApp.scriptSuite file and the
ScriptableDocApp.scriptTerminology file. If you select either one, you
should see the XML in the editor window. Now, we need to localize the
scriptTerminology file, so select the
file and from the Project menu choose "Show Info."
The Info window for ScriptableDocApp.scriptTerminology
In the info window
that appears, you should see the
file listed in the Name field and on the right there is a drop-down menu that
says "Localization & Platforms." Select "Make Localized" from this menu,
and you'll see an expansion arrow appear next to the file name in the
Resources folder. From the same "Localization & Platforms" menu, choose
"Add Localized Variant..." and in the panel that appears, click on
the right arrow and select "English." You could also just type "English" into the panel.
Adding an English localized variant of our ScriptableDocApp.scriptTerminology file.
Click on the OK button and then you can close the Info window.
Choose Build and Run from the Build menu, saving any files that need it.
Try running the script again from the Script Editor, and you should now see a new document window being created each time the script runs. If you have any trouble, you can download my ScriptableDocApp project file here.
One other interesting thing you can try is to play with the script
Terminology file. If you change "document" to be "my document," and
"documents" to be "my documents" in the
ScriptableDocApp.scriptTerminology file and then save and rebuild your
application, you will change the manner to which the
MyDocument class is referred. To
see this, you will need to quit out of the Script Editor application,
because it will cache the older version of the terminology from
ScriptableDocApp until you do, and then restart Script Editor and paste
in this script:
tell application "ScriptableDocApp" activate set w to make new my document at the beginning of my documents --close every document end tell
Run it, and you should see it work the way it did before, but now with new terminology. You can also look at the ScriptAbleDocApp's script dictionary to see how the terminology changes. One thing to be careful of when changing the script Suite or Terminology files is that Script Editor will need to be restarted in order to get the latest verison of both files. You can save your scripts as text files to save them between restarts. It is a pain, but keep in mind that the syntax and terminology for your applications won't often change, so caching is generally a good idea.
One other gotcha I have run into is that if you Clean the project, the
NSAppleScriptEnabled key will be removed from the
Info.plist file. You can
simply add this back in after cleaning, so if you suddenly find your
application is not responding to scripting at all, check to see if
Info.plist has been changed.
We are going to continue adding support for the Core Suite in ScriptableDocApp, including adding some text and the ability to load, save, and print our documents. This will mean jumping into ObjC and writing some code, so if you are not familiar with the basics of ObjC, check out Mike Beam's column or some of the tutorials that come with the Apple developer tools.
See you then.
Brad Dominy is the head of Neoki, LLC, a small web design firm located in Chicago, IL.
Return to the Mac DevCenter.
How about tutorial on IAC???
2003-05-13 07:36:34 anonymous2 [View]
2002-12-16 15:05:52 anonymous2 [View]
errors in ScriptableDocApp.scriptSuite
2002-10-01 15:51:19 anonymous2 [View]
Skip the OOP review
2002-03-05 07:21:26 snackdog [View]
Script Editor execution error alert said
2002-02-26 17:31:18 psheldon [View]
got rid of execution error alert
2002-02-26 17:50:34 psheldon [View]
2002-02-26 17:29:42 psheldon [View]
PropertyList Editor can't parse ScriptableDocApp.scriptSuite
2002-04-23 16:27:31 xyzzy-xyzzy [View]
2002-02-24 08:47:35 tib007 [View]
well you can get more general
2002-02-26 16:50:47 psheldon [View]
2002-02-23 10:26:29 email@example.com [View]
tried what you said
2002-02-26 17:34:01 psheldon [View]