Script Builder allows you to add Script Editor's compiled scripts to your Code Warrior project. They are copied into your application as 'scpt' resources. It required CW7 or later.
Suggestions and comments can be directed to me at gwatts@fnal.fnal.gov
Installation
Move the file "Script Builder" to the Code Warrior folder "CodeWarrior Plugins" folder. Quit the Code Warrior IDE if it is open, or CW will not recognize the new plugin. After starting up, open the "Target" preferences panel. After "Type:" enter "osas". Under flags select "launchable", and for Compiler select "Script Builder". Your done. You may want to modify your stationary files so you don't have to do this for every new project you create. You will have to do this for every project you've already created, however.
Creating Scripts
Use the Script Editor, that came with the Mac OS, to create scripts, or any other editor that saves compiled scripts. In the script editor, when you save a script, select the "compiled script" format.
One very important thing. Somewhere in your script you must add the string "RESID=<n>" where <n> is a resource id number (like 50). For example, here is a script from one of my applications that plays with mosaic hot lists:
-- RESID=100 CW plugin will take care of this
tell application "HotList"
try
set theFile to (choose file with prompt "Hot List To Import" of type "HOTL")
display dialog "Got it here " & theFile
make new Hot List with data theFile
on error
end try
end tell
when CW builds my app, it will create a script with a resource id of 100.
Adding Scripts To The Project
You can now add compiled scripts the same way you might add a resource file or a text file. You can drag the files onto the project window, or use the Add Files menu command.
Compiling the Scripts
CW will attempt to build the file just like any other file in the project. Script Builder will produce an error if it can't find the compiled script resource ('scpt', id=128) in the file, or it can't find the text "RESID=<n>" in the script. In CW7, when you get an error, double clicking on the error will open the script file as a text file in the code warrior editor. Bummer. I'm thinking this might be fixed in CW8, but I don't know.
The compiler output will be 'scpt' resources. The resources will have the id specified in the string "RESID=", and the name of the file. So, the above example script is stored in a file called "Import Hotlist", and the built application has a 'scpt' resource, id 100, with the name "Import Hotlist".
Using Compiled Scripts
See develop 18 and 19 for the real details. That is where I pulled all of my stuff. Basically, you load the script, and then you execute it.
I've included two classes in here that I've used to help me out. These won't compile (I think some debug files are missing) but it should be too much work to get them working. They are in C++ (if someone wants to give me some pascal snippits, I'll be happy to include them).
In my document class definition, I declare the varriable:
Then, in my ObeyCommand method, when I get the the "import hotlist..." command from the user, I do:
mImportScript.Execute ();
This may not work for you, but I really like it!
Have fun. This is freeware. If you have suggestions for other features, let me know -- I do want to keep it simple though! You can email me at gwatts@fnal.fnal.gov. This archive can be put on any online service, and can be distributed on any CD without asking me permission as long as the complete archive goes with it.