I Love AppleScript Studio
by - June 18th, 2004
Studio Sessions
Boy, the more I work with AppleScript Studio, the more I love the thing.
I don't use any commercial apps to maintain and manage my weblog. When I started YellowText in 1995, the word "blog" didn't even exist. A simple script to automatically upload an HTML file to my webserver became a more complicated script to automate the whole process, and eventually a simple AppleScript Studio app that took text from BBEdit, did a little dance with it, and then told Interarchy to post it. That's CWOBber (Colossal Waste of Bandwidth weblogger.). The goal for CWOBber2 was immediately obvious: make it a completely self-contained app with no need for external text editors or FTP apps at all. Make it slicker and easier to use. Maybe add a little, what do call it? Oh, yeah: "error reporting." That's the baby.
But if the motives for CWOBber2 were clear, the proper user interface wasn't. Over the past year or two I went through several different concepts and iterations and none of them felt right.
Why don't I just switch to LiveJournal or MoveableType? Because CWOBber isn't just my weblogger. It's a chance to keep studying new web standards and technologies and to keep learning about current Macintosh development tools. Plus, every programmer should eat his own dog food. But with CWOBber2, I was chugging Alpo as though I were on "Jackass" and someone bet me three dollars that I wouldn't.
Finally, while in London trying to make sense of British reality television, it came to me in a flash. I wanted to get it all down before I forgot about it. I launched Interface Builder (part of Apple's free XCode authoring system) and the Interface was Built inside of five minutes. I write a blog item in an editing window, I click a button marked "Publish," a sheet drops down so I can set some options, I click "Post," and it goes on my Web site. And it's all there. If I use Interface Builder's "Test Interface" feature, it behaves like a real application, too. Clicky-clicky, typey-typey, scrolley-scrolley...the only thing it won't do is, well, anything productive. It's sort of like one of those concept cars at the auto show, or any Apple CEO between John Sculley's ouster and Steve Jobs' return.
Though even the prototype is actually fairly useful, thanks to the fact that the editor centers around what's technically known as a ScrollView object. If you go into Interface Builder, create a new window, drag a ScrollView into it, and then add this to an AppleScript Studio project with no code whatsoever, you can click "Build" and you'll have 60% of a standalone word processor. The ScrollView object comes with a lot of ready-made features. You can type text into it. You can cut, copy and paste. You can Undo what you've Done. When you misspell a word, it's automatically underlined in red. The text automatically wraps to the width of the ScrollView and when the user resizes the window, the content dynamically resizes itself automagically. AppleScript Studio adds the usual gang of menus and adds them to your project on its own, and whaddya know: the "Print" command more or less works, too.
I really don't have time to work on CWOBber2 until I finish this next book of mine. The deadline is only days away and friends, I'm keeping my passport within reach just in case. But earlier this week I wanted to see if the interface worked well even with a huge, blog-sized pile of text in the editing window. Reflexively I dragged a text file into it from the Desktop but it didn't work. Oops...I forgot that you can't drag-and-drop into a whatsis unless you add a little bit of code to tell the thingamabob what kinds of data it should be willing to accept. 'TEXT' please, thank you, that's lovely. Two lines of AppleScript. Build. And now this empty shell of an app has full drag-and-drop functionality.
A couple of days later, I was looking at CWOBber2's interface again. The text looked kind of small. What would be the ideal type size? I didn't know. I supposed it would depend on whether I was using the app on Lilith 7 (my PowerBook, where the screen is just 16 inches away on my lap) or my desktop Mac (where it's a full two or three feet). I went back into Interface Builder and dragged a miniature popup menu to the editing window. Five lines of code later and it was all wired up. Build. And now I can change the font size whenever I want.
I also set the editor's font to something nicer than the Helvetica default. Well, golly: this is starting to look like a real application! Yesterday I got stuck searching for Le Mot Juste and I turned once again to the CWOBber2 editing window for a little diversion. There's an invisible TextField object that CWOBber2 will use for little status messages that don't merit a full-on warning dialog. Folks, word count is the bane of my existence. Every time I write something for publication my time is split 20-80. I spend 20% of my time writing the thing and then 80% trying to eviscerate the Flawless Gem of Perfect Truth, Beauty and Wisdom I've just created into the 800 words I'm actually permitted.
So when I'm right on my deadline and editors are sending me uncomfortable e-mails regarding how cheap it'd be to Priceline a ticket to Boston and how easy it would be for them to buy a gun once they got here, time is of the essence; I desperately need to keep an eye on my word count. I don't want to have to click anything to discover that Wile E. Coyote's rocket-powered roller skates have no "Off" switch and he's approaching the edge of the cliff at a distressing rate of speed. How hard would it be to add a feature to CWOBber so it gives me a live word count as I type?
Not terribly. Word count is just one line of AppleScript ('set thisVariable to the number of words in the text view of the scroll view "newBlogContent"' is literally it, I think). Turning this number into a few words of text and then sticking it in the editing window's status thingy is just another line or two. I tell Interface Builder that it needs to execute this script every time someone stops typing in that scroll view and it's done. Build.
I had a newspaper column due this afternoon. Been so busy that I didn't even start it until the AM. Clicked into BBEdit and created a new document as usual, and after I'd written the two lead paragraphs I suddenly stopped.
After a moment's thought I did a Select All, dragged the selected text into CWOBber2's editing window -- the window where practically nothing was wired up, the window where basically all I'd done was draw what the user-interface should eventually look like -- and I wrote the rest of my column.
And...well, damn. I liked using this slapped-together word processor. Liked it even more than BBEdit. Or should I say, I like it; I'm using the proto-CWOBber2 to write this column as well. BBEdit has earned a very special place in my heart. I preferred it to Word for most of my writing because it has a quick, clean, concise interface and it never ever ever changes "iMac" to "IMac" (or does anything else that might lead to PowerBook-shaped dents in my office drywall) without my asking it to. But it doesn't spell-check interactively and I have to click a button to get a word count. And after that, I have to click another button to get the word count window out of the way
There was a long stretch of my life during which I didn't write a scrap of software. Somewhere during the late Eighties it stopped being fun. When I was a tiny kid and I first learned to program, you could write 'em big or you could write 'em small. You could get immediate results from just a few lines of code, and the magic of Making Your Computer Do Something spurred you on to Make It Do Even More. Software wasn't engineered: it was grown from little seeds.
But then operating systems got way more complicated. True, making a Mac go "Beep!" was just one command, but you needed to write four pages of infrastructure before the compiler recognized that the thing you had just typed into its code-editing window was meant to be an actual working piece of software.
If you wanted it to go "Beep!" after a button was pressed...well, holy cow. Tell your significant other to find someone to sleep around with, because you were going to be very inattentive life-partner for the foreseeable future.
AppleScript is still by far the most fun I have writing code. Once again, I'm growing software. I'm not submitting myself to three days in The Bunker focusing 100% on trying to build as much of CWOBber2 in one go as I can. I just need to pour myself little shot glasses of interest and curiosity. Your app arises from the ground like a skyscraper, with little bits of structure appearing every day and a new floor being completed every week, until you find yourself with a useful application on your hands. You're partly convinced that elves are logging into your Mac remotely every night and adding bits of code on their own (after the world's last kind-hearted old cobbler was driven into bankruptcy by cheap Korean labor, they decided to update their skills; very wise...American textile workers would do well to learn by their pointy-hatted example). How else is this app growing the way it is? You just don't remember ever doing that much with this project.
AppleScript Studio reminded me that writing software is creative and energizing and exciting. Like a kid with an unplayed beta of Halo 2, I had to remind myself that deadlines loomed over the immediate horizon and that I should not, should not, should not wire up that "Publish" button so that it would take the column I just wrote and e-mail it to my editor automatically. Even though I knew it would have required a dozen lines of code, max, and perhaps twenty minutes of my time. Ditto for making the color of the interactive word count creep slowly from black to bright red the closer I get to my word count. Ditto for...
With the possible exceptions of singing at family weddings and giving your boss the severe beating he so richly deserves, anytime you have to be directly restrained from an activity, you know you're in a unique and highly positive environment.
digs the Mac, and has been writing about the Mac for longer than most of us could tell the difference between a bite of Apple Sauce from a byte of Apple code. You can read his monthly column at Macworld magazine, and his blog at the Colossal Waste of Bandwidth.
Andy's latest book is The Mac OS X Tiger Book (US$16.49 - Amazon).
You can send your comments directly to Andy, or you can also post your comments below.
Most Recent Columns From Andy Ihnatko
- You Can't Spell 'Speculate' without 'Peas' - February 22nd
- So: It's A Video iPod. Sweet! - October 13th
- How to Stuff a Wild iPod - October 13th
Andy Ihnatko's Archives
Observer Comments
I, like many, have been looking for a Movable Type replacement. My old install bit the dust during a server upgrade and I had been waiting for the new version. That went to heck when the pricing was announced.
For a few weeks I've been giving thought to a script I created a number of years ago to convert a Quark (later InDesign) file to a web page to automate the process of issuing news releases I do on a regular basis.
The AppleScript Studio interface would be the perfect way to move this script from concept to completion for purposes of a blog.
Thanks for the kick in the pants.
I've dabbled with AppleScript since Ircle became scriptable (some time ago) and shell scripting since OSX's inception. Call me a minimalist but sometimes a shell script is all it takes for quickening a task. But with Xcode and AppleScript Studio I may just start giving those CLI scripts a facelift of the Aqua kind. Thanks Andy!
Hello Andy.
I enjoyed this article and I don't normally post comments...but felt I spurred on by your enthusiams about "word count".
You wrote: "Folks, word count is the bane of my existence."
It seems as though there is always an area in the digital existence we find ourselves living in when there are word limitations being put on an individual. Now I am not a programmer...I am a user who just wants to be able to use the technologies to accomplish a particular task.
Lately it seems I have been experiencing situations on websites where I am limited to 200 word text blocks. Typically for descriptions of an item for sale on the internet. Shouldn't there be a programmers law that states "If I put a limitation on characters for a user to have available for information input, thou shalt put a word counter". Or something like that...I'm not a writer either.
Anyway...I thought since you were a programmer I would throw that out there. I am glad to read that you include a word counter in your software...if I start to blog I'll see if you have a product ready for me to try out.
Thanks for the great article.
Have a great day.
Sincerely,
Joseph
josephaboothii@mac.com
Tue Jun 29, 2004 11:28 am Subject: Applescripting
Comments are currently closed. Please email the author instead.
Recent Headlines - Updated November 8th
- Sat, 7:58 PM
- News - Apple TV 3.0.1 Update Fixes Missing Content Bug
- Fri, 7:45 PM
- Rumor - Taiwan Leak Shows Verizon UTMS/CDMA iPhone for Q3 2010
- 6:40 PM
- News - iPhone Moves Into RadioShack
- 6:30 PM
- News - Apple to Open Stunning Paris Apple Store in Le Louvre on Saturday
- 5:43 PM
- Free on iTunes - Dictionary, Dictionary, Dictionary, And More
- 4:09 PM
- John Martellaro's Blog - Particle Debris (week ending 11/6) Failure IS an Option
- 3:32 PM
- Games - The Latest App Store Games: Gravity Sling, RocketBird, Ground Effect, Checkers!
- 2:25 PM
- Games - Star Soccer 2010 for Mac Puts Gamers in Role of Up-and-Coming Player
- 2:15 PM
- How-To - The Mysteries of Rosetta Housekeeping
- 1:33 PM
- News - iPhone Game Developer Sued for Collecting User’s Cell Numbers
- 1:17 PM
- Games - Warhammer Online Expands Trial Play Option
- 11:19 AM
- Rumor - Apple May Be Bringing RFID to the iPhone
The Mac Observer Reader Specials
- TypeStyler For Mac OS X is Now Shipping! Download The Free Fully Functional 60 Day Tryout at www.typestyler.com
RamJet Memory: Mac Pro 8-core 8GB Kit $199.99, 4GB Kits $109.99! Sale on MacBook and MacBook Pro 8GB kits $549.99! New MacBook DDR3 2GB for $49.99. iMac and Mac mini 4GB Kits for $79.99! 1TB SATA Hard Drives for $109.99! Click here
OWC: We Make DIY Upgrading Easy! Maximize your Apple MacBook / MacBook Pro. Up to 8.0GB Memory, up to 1.0TB HD & More. Easy Guide + Free, Detailed Installation Videos. Click here
If you're using a Mac, then you've gotta check out Full Tilt Poker for Mac. This Full Tilt Poker bonus code does the unthinkable, it actually rewards!For the latest Apple products use Ciao, a price comparison website, to find laptops like MacBook Air. Then find the best prices on MP3 players and use our comparison tool to evaluate mobile phones like the Apple iPhone.
Laptop Hardware Provided by TechRestore - Overnight Mac & iPod Repairs.

