About Elegant Chaos
About me and my friends
Software from Elegant Chaos
Other stuff...

Script Runner

The current version is 1.2
(Version 1.4, which is Carbonised, is currently in beta testing.
You can download a pre-release copy here.)

Script Runner is a post linker plugin for Codewarrior. What it does is execute an AppleScript (or in fact any application) when Codewarrior reaches it's post link stage (e.g. after all the linking has completed).

Script Runner passes the location of the linked file to the script, along with some other information. This allows the script to do all sorts of useful things with the linked file, for example give it a custom icon, make a copy in another location, make a stuffit archive, etc.

You can download script runner here. Script Runner is Copyright (C) 1999 Elegant Chaos. All Rights Reserved. It is covered by our standard software disclaimer.

Script Runner is $25 shareware. You can pay for it online using a secure form and a credit card, or by post, phone or fax using a registration program, which you can download here. Once you have paid, you will be sent a registration code, which you can enter by clicking the "register" button in the preferences panel for the plug-in. Until you have registered, Script Runner will pause for a few seconds after each compilation. The longer you've been using Script Runner for, the longer this pause gets!


To install Script Runner, you need to put two files into your "Codewarrior Plugins" folder. Drop the "Script Runner" file into the "Linkers" folder, and the "Script Runner Panel" file into the "Preference Panels" folder. You will need to re-launch codewarrior to get it to recognise the new plugins.

Using Script Runner

Open the preferences for the project and target that you want to use Script Runner with. Select the "target settings" panel, pop-up the "Post-linker" menu, and choose "Script Runner" from the menu.

Now select the "Script Runner" panel (in the Linker section). You will see two text boxes and some buttons.

The top text box contains the name or path of the applet (or application) that you want to run. If you select the 'absolute path' radio button, you can specify the exact location of the script as a full path (the button on the right allows you to choose this file without having to type the path in). Alternatively, you can select the 'in access paths' radio button, and just enter the name of the script that you want to execute. The plug-in will search for the script using the project's access paths, just like CodeWarrior does with source files.

Anything you type into the bottom box will get passed to the script as a parameter. If your scripts start getting fancy then you may find this useful!

Normally, the plug-in waits for the script to return a result (or error), before completing the build operation. If you click the 'ignore script result' checkbox, the script's result will be ignored.

That's it. Couldn't be easier... except that I suppose you'll be wanting to know...

Writing Scripts For Script Runner

Script Runner sends a custom apple event to the applet/application. Since Applescript doesn't have any terminology resource to look in, it can't convert the event type and parameters into nice sensible words - resulting in a script that looks a bit ugly. Do not fear though - it's really very simple!

Your script should be saved as an Application, with the "Stay Open", and "Never Show Startup Screen" options checked. Setting the "stay open" option means that the Applet will continue to run after the post-link event has completed. If you want it to quit, you can use the 'link done' event to send the "quit" command to the applet once the linking has completed.

Here's a shell for you to use:

    on «event ECpllaun»
      -- this event sent when script is launched - you can do setup here
    end «event ECpllink»
    on «event ECpllink» of built ¬
        given «class tSYS»:system, 
               «class tCPU»:cpu,
               «class tCRE»:creator,
               «class tTYP»:type,
               «class tSYM»:symfile,
               «class tRUN»:runfile,
               «class args»:args
        -- this event sent to do the post-link - do your stuff here
    end «event ECpllink»

    on «event ECpldone»
      -- this event sent when post link is done - you can quit the applet here
end «event ECpllink»

The built parameter is the file that's just been linked. The other optional parameters are:

If you are still confused, I suggest examining the example scripts that I've included.