TweetFollow Us on Twitter

Satimages Smile

Volume Number: 16 (2000)
Issue Number: 10
Column Tag: Tools of the Trade

Satimage's Smile

by Tom Djajadiningrat

AppleScript IDE

Introduction

Smile is an AppleScript integrated development environment which is highly scriptable itself. It offers a fine text editor, pretty good documentation and the possibility to look up definitions from within the editor. But Smile's most amazing features are its ability to execute a script line-by-line from a seemingly ordinary text window and that its interface can be customized at will.

Since it is essentially free - all SatImage asks is your feedback to further improve Smile - it makes a great replacement for the standard Apple Script Editor. After a while you realize that Smile is much more than that. It brings together in a single application a combination of features which force you to rethink the possibilities of AppleScript.

Requirements

A Superior Editor

Despite its name, the editing features of Apple's Script Editor have always been somewhat poor. Especially its lack of drag-and drop and search-and-replace is rather annoying. Smile is worth getting just for these features. In addition, Smile features live scrolling, can compare files, has no 32k size limit, and implements Appearance. Command clicking the title bar of a window gives CodeWarrior-like access to its file's path (Figure 1). This in combination with support for Navigation Services makes organizing files much easier.


Figure 1. Smile provides easy access to a file's path.

If you are a keyboard animal then you will appreciate that keyboard navigation and selection are fully implemented. Jump word (option + left/right arrow key), jump start/end of line (command + left/right arrow key), page up/down (option + up/down arrow key) and home/end of document (command + up/down arrow key) and the selection equivalents with the shift key held down: it's all there.

Documentation

Smile comes with a guided tour in its own file format. It is clear and concise, taking about 10-15 minutes to work through. More elaborate documentation can be found within the Help menu. Smile's documentation makes use of Apple's Help Viewer and turns up as an option within the Help Center (Figure 2). If you get totally stuck with Smile you can subscribe to the Smile mailing list as described in the help.


Figure 2. Smile's help turns up in the Apple Help Center.

A Different Philosophy

If you like you can write scripts straight within a script window just as in the Script Editor. However, there is a far more powerful way to use Smile. Scripts can be written in a text window and a single line or piece of the code can be executed simply by selecting it and pressing enter (For those familiar with Mathematica this is somewhat similar to selecting cells and pressing enter after each one). This allows much flexibility during development as you can execute pieces of script in an order of your choosing. It also allows you to leave pieces of code hanging about without the need to comment them out. Once a script works to your satisfaction, you can copy it to a script window and save it in the usual variety of formats.

Apart from script windows and text windows Smile uses a worksheet and output windows, making four different types of window in total. Figure 3 shows all four at the same time. Let's have at each of them.

Worksheet

This is like a single page Scrapbook particular to Smile. Here you can store text and images which you use over and over again in different scripts, such as a copyright notice, those code samples you can never remember or logos. The result of executing a script in a script window is appended to the worksheet. The worksheet is saved automatically on quit and opened automatically when you start up Smile.

Text Window

During script development a text window is like a scratch pad. In a text window you can try out pieces of code in any order. You can have multiple text windows holding different versions of your code. When a piece of script in a text window is executed, the result shows up at the bottom of the same window. That is, unless you specify an...

Output Window

Selecting a text window and choosing Output window from the script menu creates a new window and redirects the output to that new window. You can also link an output window to a script window instead of to a text window. Then the output of the script window does not end up in the worksheet but in the output window.

Script Window

As mentioned before, you move your script to a script window once you wish to save it as an applet. The script window distinguishes itself visually by a comments area at the top, a coloured background, and a small toolbar at the bottom. Unlike a text window a script window does not allow execution of code line by line, it only allows you to run a whole script.


Figure 3. The four types of window in Smile: script window (top left), text window (top right), output window (bottom right) and worksheet (bottom left).

Decent Debugging

'Step-by-step' debugging

Let's go back to executing code in a text window. Putting the cursor on a line and pressing enter executes that line of code and advances the cursor to the start of the next line. So by pressing enter repeatedly you can step through the code. It even works properly with lines that are broken with option-return (¬). Note how we almost have step-by-step debugging here. Well, almost but not quite. You need to watch out for a few complications.

If you use a tell block to direct commands to a particular application you can't just step into the tell block: Smile will choke on the first line tell application "x" and display an error message (Figure 4). It does work if you select the whole tell block and press enter, but of course you loose resolution: if things go wrong you don't know which line within the block formed the culprit. Another option is to add tell application "x" to every line though this is a somewhat cumbersome solution.


Figure 4. Stepping into a tell block brings up an error message

This is where the tell command from the edit menu comes in (Figure 5). It lets you link a Smile text window to a particular application so that commands are directed at that application. Choosing the tell command makes a dialog box appear in which you can choose an application that is running on either the local or a remote machine (Figure 6). This turns on a small popup menu in the bottom left corner of a text window (Figure 7). Any script commands are now directed to the application you just linked to unless you speciÞcally ask them to be directed elsewhere. So you no longer need to wrap the commands for the linked app in a tell block or use a tell command on every line. Choosing logout from the popup menu breaks the link to the application (Figure 7).


Figure 5. Use the tell command to direct AppleScript commands to a particular applicaion.


Figure 6. Specify the application to link to. Here only the local host with its processes is shown.


Figure 7. The tell-related popup menu.

Variable watching

To further facilitate debugging Smile offers a variable watching window. After dragging or typing in a variable name in this window Smile will show its type and value during execution (Figure 8).


Figure 8. The variable watcher showing an integer, a real and a string.

Help with AppleScript Syntax

In addition to the open dictionary command familiar from Script Editor, Smile has got some extra features to help you with AppleScript syntax problems. First, you can select Find Definition from the Edit menu which will try to find the string in Smile's dictionary (or if you just linked to another app, that app's dictionary) or in a scripting addition. Second, if you need help with the AppleScript syntax of an application that you are linked to through the tell command you can choose Dictionary from the popup menu in the bottom left hand corner (Figure 7). I noticed that Smile chokes on the dictionary of Palm Desktop, while Script Editor has no problems with it. Finally, Smile's own dictionary is available under the Apple menu.

Advanced Stuff

Portability

Let's have a brief look at the somewhat more advanced stuff Smile has to offer. One nice feature is that it can assist you in writing portable code in which the normal English like AppleScript commands are replaced by raw codes. For example, if you want to script a particular application you may run into the problem that a particular user has a localized version of that app with a localized name (like SimpleText being called SimpelTekst in Dutch) or a version with a slightly different name (like BBEdit 5.x instead of 4.x). If you want the script to run smoothly and prevent a choose application dialog box from popping up you can look up the application by creator code instead of by name and resolve the name of the application at runtime. However, this means you cannot use the normal English-like commands as found in the app's dictionary, you will have to use the raw codes. If you first link to a particular application through the tell command you can then use the Copy Translate feature from the bottom left popup menu to change the selected text to raw codes (Figure 7).

Attachable and factored

Smile is not only scriptable and recordable, it also has those more rare AppleScript virtues: it is attachable, allowing scripts to be attached to its objects, and factored. What factored comes down to is that when the user chooses a certain command Smile sends an Apple event to itself instructing itself to execute the command rather than execute it directly. This ensures that Smile reacts in exactly the same way regardless of whether the Apple event originated from within or from outside Smile. This attachable and factored architecture is particularly powerful in combination with...

Custom interfaces

You can build your own custom interface for controlling Smile and AppleScripts. For example, you can add buttons to text windows to create so called Smile sheets and put up your own dialog boxes. Option-command clicking a button or dialolg opens the attached script. Pretty impressive stuff. Even the Variable Watcher is really a Smile sheet. When it comes to customization you are pretty much on your own though as the documentation concerning this feature is rather skimpy.

Interface Critique

Smile's interface could do with a little tidying up. Especially the script menu deserves some attention. At the moment it is a bit of a hodge-podge of all kinds of little tidbits provided by SatImage. As this is also the menu in which the user can place his own scripts, the structure of this menu can only get worse.

Then there is the linking of output windows to text or script windows. To me this seems a pretty essential component of the Smile philosophy, yet the command lives under the scripts menu. Since choosing output window essentially creates a special kind of text window the command would seem to be more at home under the file menu. I also found it a shame that the format of an output window is stubby and wide below the text window to which it is connected. The consequence is that any results quickly scroll out of view. I would prefer to have a tall and narrow output window, positioned to the side of the text window, so that older results remain visible and the most is made of the available screen real estate.

The Balance command's name does not do it justice. It suggests that the command is limited to indicating or closing unbalanced parentheses. However, it is in fact far more powerful than that. It can also suggest syntax, colourize indentation levels and assist you in writing tell statements, depending on what part of your script is selected before you activate it.

Finally, I find it a bit of a shame that a selection in a read-only document is not highlighted. The idea of having scripts embedded in read-only documents is quite tempting. It does not feel quite right though if you cannot see what you have selected before you press enter. Other applications, such as Tex-Edit Plus, do highlight selections within read-only documents.

More Information

While Smile seems to have gained quite a bit of momentum amongst hardcore AppleScript fans, it does not appear to be very well known among the Mac community at large. Here are some URLs to help you explore further:

Conclusion

They say you can't look a gift horse in the mouth but Smile easily stands up to scrutiny. Most of my gripes concern the interface which deserves some more attention. All in all this is a great addition to the AppleScript scene though. The editing features, powerful lookup functions, line-by-line execution and variable watching make Smile far superior to Apple's Script Editor. The idea of system wide control from scripts which happily live together with styled text and graphics in a single document is fascinating. More advanced scripters will appreciate the support for portable code, the possibilities to script Smile itself and the customizability of its interface through Smile sheets and dialogs. The nicest thing about Smile is probably its gradual but seemingly insaturable learning curve: it is easy to pick up but it is difficult to imagine exhausting its possibilities.


Since being involved in the re-design of the id-StudioLab web pages <http://www.io.tudelft.nl/id-studiolab/djajadiningrat/> Tom has got an even stronger opinion about layout and HTML. If you enjoy getting empty mail messages ask him for it with all four letter words left out at <J.P.Djajadiningrat@io.tudelft.nl>.

 

Community Search:
MacTech Search:

Software Updates via MacUpdate

Latest Forum Discussions

See All

Tokkun Studio unveils alpha trailer for...
We are back on the MMORPG news train, and this time it comes from the sort of international developers Tokkun Studio. They are based in France and Japan, so it counts. Anyway, semantics aside, they have released an alpha trailer for the upcoming... | Read more »
Win a host of exclusive in-game Honor of...
To celebrate its latest Jujutsu Kaisen crossover event, Honor of Kings is offering a bounty of login and achievement rewards kicking off the holiday season early. [Read more] | Read more »
Miraibo GO comes out swinging hard as it...
Having just launched what feels like yesterday, Dreamcube Studio is wasting no time adding events to their open-world survival Miraibo GO. Abyssal Souls arrives relatively in time for the spooky season and brings with it horrifying new partners to... | Read more »
Ditch the heavy binders and high price t...
As fun as the real-world equivalent and the very old Game Boy version are, the Pokemon Trading Card games have historically been received poorly on mobile. It is a very strange and confusing trend, but one that The Pokemon Company is determined to... | Read more »
Peace amongst mobile gamers is now shatt...
Some of the crazy folk tales from gaming have undoubtedly come from the EVE universe. Stories of spying, betrayal, and epic battles have entered history, and now the franchise expands as CCP Games launches EVE Galaxy Conquest, a free-to-play 4x... | Read more »
Lord of Nazarick, the turn-based RPG bas...
Crunchyroll and A PLUS JAPAN have just confirmed that Lord of Nazarick, their turn-based RPG based on the popular OVERLORD anime, is now available for iOS and Android. Starting today at 2PM CET, fans can download the game from Google Play and the... | Read more »
Digital Extremes' recent Devstream...
If you are anything like me you are impatiently waiting for Warframe: 1999 whilst simultaneously cursing the fact Excalibur Prime is permanently Vault locked. To keep us fed during our wait, Digital Extremes hosted a Double Devstream to dish out a... | Read more »
The Frozen Canvas adds a splash of colou...
It is time to grab your gloves and layer up, as Torchlight: Infinite is diving into the frozen tundra in its sixth season. The Frozen Canvas is a colourful new update that brings a stylish flair to the Netherrealm and puts creativity in the... | Read more »
Back When AOL WAS the Internet – The Tou...
In Episode 606 of The TouchArcade Show we kick things off talking about my plans for this weekend, which has resulted in this week’s show being a bit shorter than normal. We also go over some more updates on our Patreon situation, which has been... | Read more »
Creative Assembly's latest mobile p...
The Total War series has been slowly trickling onto mobile, which is a fantastic thing because most, if not all, of them are incredibly great fun. Creative Assembly's latest to get the Feral Interactive treatment into portable form is Total War:... | Read more »

Price Scanner via MacPrices.net

Early Black Friday Deal: Apple’s newly upgrad...
Amazon has Apple 13″ MacBook Airs with M2 CPUs and 16GB of RAM on early Black Friday sale for $200 off MSRP, only $799. Their prices are the lowest currently available for these newly upgraded 13″ M2... Read more
13-inch 8GB M2 MacBook Airs for $749, $250 of...
Best Buy has Apple 13″ MacBook Airs with M2 CPUs and 8GB of RAM in stock and on sale on their online store for $250 off MSRP. Prices start at $749. Their prices are the lowest currently available for... Read more
Amazon is offering an early Black Friday $100...
Amazon is offering early Black Friday discounts on Apple’s new 2024 WiFi iPad minis ranging up to $100 off MSRP, each with free shipping. These are the lowest prices available for new minis anywhere... Read more
Price Drop! Clearance 14-inch M3 MacBook Pros...
Best Buy is offering a $500 discount on clearance 14″ M3 MacBook Pros on their online store this week with prices available starting at only $1099. Prices valid for online orders only, in-store... Read more
Apple AirPods Pro with USB-C on early Black F...
A couple of Apple retailers are offering $70 (28%) discounts on Apple’s AirPods Pro with USB-C (and hearing aid capabilities) this weekend. These are early AirPods Black Friday discounts if you’re... Read more
Price drop! 13-inch M3 MacBook Airs now avail...
With yesterday’s across-the-board MacBook Air upgrade to 16GB of RAM standard, Apple has dropped prices on clearance 13″ 8GB M3 MacBook Airs, Certified Refurbished, to a new low starting at only $829... Read more
Price drop! Apple 15-inch M3 MacBook Airs now...
With yesterday’s release of 15-inch M3 MacBook Airs with 16GB of RAM standard, Apple has dropped prices on clearance Certified Refurbished 15″ 8GB M3 MacBook Airs to a new low starting at only $999.... Read more
Apple has clearance 15-inch M2 MacBook Airs a...
Apple has clearance, Certified Refurbished, 15″ M2 MacBook Airs now available starting at $929 and ranging up to $410 off original MSRP. These are the cheapest 15″ MacBook Airs for sale today at... Read more
Apple drops prices on 13-inch M2 MacBook Airs...
Apple has dropped prices on 13″ M2 MacBook Airs to a new low of only $749 in their Certified Refurbished store. These are the cheapest M2-powered MacBooks for sale at Apple. Apple’s one-year warranty... Read more
Clearance 13-inch M1 MacBook Airs available a...
Apple has clearance 13″ M1 MacBook Airs, Certified Refurbished, now available for $679 for 8-Core CPU/7-Core GPU/256GB models. Apple’s one-year warranty is included, shipping is free, and each... Read more

Jobs Board

Seasonal Cashier - *Apple* Blossom Mall - J...
Seasonal Cashier - Apple Blossom Mall Location:Winchester, VA, United States (https://jobs.jcp.com/jobs/location/191170/winchester-va-united-states) - Apple Read more
Seasonal Fine Jewelry Commission Associate -...
…Fine Jewelry Commission Associate - Apple Blossom Mall Location:Winchester, VA, United States (https://jobs.jcp.com/jobs/location/191170/winchester-va-united-states) Read more
Seasonal Operations Associate - *Apple* Blo...
Seasonal Operations Associate - Apple Blossom Mall Location:Winchester, VA, United States (https://jobs.jcp.com/jobs/location/191170/winchester-va-united-states) - Read more
Hair Stylist - *Apple* Blossom Mall - JCPen...
Hair Stylist - Apple Blossom Mall Location:Winchester, VA, United States (https://jobs.jcp.com/jobs/location/191170/winchester-va-united-states) - Apple Blossom Read more
Cashier - *Apple* Blossom Mall - JCPenney (...
Cashier - Apple Blossom Mall Location:Winchester, VA, United States (https://jobs.jcp.com/jobs/location/191170/winchester-va-united-states) - Apple Blossom Mall Read more
All contents are Copyright 1984-2011 by Xplain Corporation. All rights reserved. Theme designed by Icreon.