The simplest AppleScript for BBEdit

Here is the first AppleScript that I have written. Despite the simplicity of my objectives, and knowing that BBEdit was scriptable, and having looked at a few scripts before, this script still took most of a day to write. The difficulty was that although there were lots of good script tutorials very few dealt with the scripting of a text window at such a basic level. Today (20040821) Apple's Scriptable Apps page provides no script example for TextEdit :-(

-- This script generates the HTML sequence for my 'up-arrow' navigation link
-- It replaces any selection in the text with the string between quotes.
-- If there isn't a selection then the string goes in at the insertion
-- point.

tell window 1 of application "BBEdit"
set contents of the selection to "<big> &uarr;</big>"
end tell

I'm not resorting to Perl for this job yet. Just how different can two scripting languages be?

[ Software development]
Last modified: 2004 August 22nd.