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

Top Mobile Game Discounts
Every day, we pick out a curated list of the best mobile discounts on the App Store and post them here. This list won't be comprehensive, but it every game on it is recommended. Feel free to check out the coverage we did on them in the links... | Read more »
Price of Glory unleashes its 1.4 Alpha u...
As much as we all probably dislike Maths as a subject, we do have to hand it to geometry for giving us the good old Hexgrid, home of some of the best strategy games. One such example, Price of Glory, has dropped its 1.4 Alpha update, stocked full... | Read more »
The SLC 2025 kicks off this month to cro...
Ever since the Solo Leveling: Arise Championship 2025 was announced, I have been looking forward to it. The promotional clip they released a month or two back showed crowds going absolutely nuts for the previous competitions, so imagine the... | Read more »
Dive into some early Magicpunk fun as Cr...
Excellent news for fans of steampunk and magic; the Precursor Test for Magicpunk MMORPG Crystal of Atlan opens today. This rather fancy way of saying beta test will remain open until March 5th and is available for PC - boo - and Android devices -... | Read more »
Prepare to get your mind melted as Evang...
If you are a fan of sci-fi shooters and incredibly weird, mind-bending anime series, then you are in for a treat, as Goddess of Victory: Nikke is gearing up for its second collaboration with Evangelion. We were also treated to an upcoming... | Read more »
Square Enix gives with one hand and slap...
We have something of a mixed bag coming over from Square Enix HQ today. Two of their mobile games are revelling in life with new events keeping them alive, whilst another has been thrown onto the ever-growing discard pile Square is building. I... | Read more »
Let the world burn as you have some fest...
It is time to leave the world burning once again as you take a much-needed break from that whole “hero” lark and enjoy some celebrations in Genshin Impact. Version 5.4, Moonlight Amidst Dreams, will see you in Inazuma to attend the Mikawa Flower... | Read more »
Full Moon Over the Abyssal Sea lands on...
Aether Gazer has announced its latest major update, and it is one of the loveliest event names I have ever heard. Full Moon Over the Abyssal Sea is an amazing name, and it comes loaded with two side stories, a new S-grade Modifier, and some fancy... | Read more »
Open your own eatery for all the forest...
Very important question; when you read the title Zoo Restaurant, do you also immediately think of running a restaurant in which you cook Zoo animals as the course? I will just assume yes. Anyway, come June 23rd we will all be able to start up our... | Read more »
Crystal of Atlan opens registration for...
Nuverse was prominently featured in the last month for all the wrong reasons with the USA TikTok debacle, but now it is putting all that behind it and preparing for the Crystal of Atlan beta test. Taking place between February 18th and March 5th,... | Read more »

Price Scanner via MacPrices.net

AT&T is offering a 65% discount on the ne...
AT&T is offering the new iPhone 16e for up to 65% off their monthly finance fee with 36-months of service. No trade-in is required. Discount is applied via monthly bill credits over the 36 month... Read more
Use this code to get a free iPhone 13 at Visi...
For a limited time, use code SWEETDEAL to get a free 128GB iPhone 13 Visible, Verizon’s low-cost wireless cell service, Visible. Deal is valid when you purchase the Visible+ annual plan. Free... Read more
M4 Mac minis on sale for $50-$80 off MSRP at...
B&H Photo has M4 Mac minis in stock and on sale right now for $50 to $80 off Apple’s MSRP, each including free 1-2 day shipping to most US addresses: – M4 Mac mini (16GB/256GB): $549, $50 off... Read more
Buy an iPhone 16 at Boost Mobile and get one...
Boost Mobile, an MVNO using AT&T and T-Mobile’s networks, is offering one year of free Unlimited service with the purchase of any iPhone 16. Purchase the iPhone at standard MSRP, and then choose... Read more
Get an iPhone 15 for only $299 at Boost Mobil...
Boost Mobile, an MVNO using AT&T and T-Mobile’s networks, is offering the 128GB iPhone 15 for $299.99 including service with their Unlimited Premium plan (50GB of premium data, $60/month), or $20... Read more
Unreal Mobile is offering $100 off any new iP...
Unreal Mobile, an MVNO using AT&T and T-Mobile’s networks, is offering a $100 discount on any new iPhone with service. This includes new iPhone 16 models as well as iPhone 15, 14, 13, and SE... Read more
Apple drops prices on clearance iPhone 14 mod...
With today’s introduction of the new iPhone 16e, Apple has discontinued the iPhone 14, 14 Pro, and SE. In response, Apple has dropped prices on unlocked, Certified Refurbished, iPhone 14 models to a... Read more
B&H has 16-inch M4 Max MacBook Pros on sa...
B&H Photo is offering a $360-$410 discount on new 16-inch MacBook Pros with M4 Max CPUs right now. B&H offers free 1-2 day shipping to most US addresses: – 16″ M4 Max MacBook Pro (36GB/1TB/... Read more
Amazon is offering a $100 discount on the M4...
Amazon has the M4 Pro Mac mini discounted $100 off MSRP right now. Shipping is free. Their price is the lowest currently available for this popular mini: – Mac mini M4 Pro (24GB/512GB): $1299, $100... Read more
B&H continues to offer $150-$220 discount...
B&H Photo has 14-inch M4 MacBook Pros on sale for $150-$220 off MSRP. B&H offers free 1-2 day shipping to most US addresses: – 14″ M4 MacBook Pro (16GB/512GB): $1449, $150 off MSRP – 14″ M4... Read more

Jobs Board

All contents are Copyright 1984-2011 by Xplain Corporation. All rights reserved. Theme designed by Icreon.