Satimage Previous
Compiled scripts
Home Documentation Smile Compiled scripts  
Introduction

Script windows have a colored background. They are where you edit compiled scripts, applets (that is, scripts that you can launch as a standalone application), and scripts attached to Smile's objects (for instance, a script attached to a dialog window).

To make a new script window, select the File ▸ New ▸ New script menu item.

Compiling and running a script

In a script window, ^⌘R (ctrl-cmd-R) compiles the whole script and displays the compilation errors if there are any (⌥⌘R also checks for undefined variables).

There are several ways to run a script contained in a script window.

  • The window being the front window, press ⌘R or select the Scripting ▸ Run script menu item. To stop a script which is running, press ⌘. (cmd-period) or the esc key. There is no button nor a menu item to stop the script.

  • If the script belongs to an applet, double-click the applet in Finder.

  • If the script is a file located in one of Smile's User Scripts folders, the User Scripts menu displays the file's name, and selecting that item in the menu will run the script. This is explained in more details in the page entitled The User scripts menu.

The Handlers menu

The Handlers menu in the window's toolbar displays the list of the handlers of the script. To display the list in alphabetical order, pull down the menu with the 'option' key pressed. You can have the Handlers menu display additional comments: any line in your script starting with -- mark will display in the menu the fraction of the line following mark.
-- mark -
-- mark interface handlers
-- mark -
on do menu the_cmd to the_object
    [...]
You can hide the toolbar with the button in the right corner of the window's title bar.
Saving a script
Saving a regular script document

To save a script, select File > Save ⌘S or File > Save as ⇧⌘S. If you are saving an unsaved script window, or if you select Save as, the Format menu in the Save dialog box offers the several options for saving a compiled script.

If the script contains syntax errors it cannot compile and Smile will not let you save it as a compiled script, nor under any other form. To save it all the same copy the content of the window into a new text window and save the latter as a text document.

Saving an applet or a droplet

AppleScript can make a compiled script into a stand-alone application: an applet or a droplet. To save a script as an applet, choose Format ▸ Application in the Save dialog. Like in Script Editor, if the script includes a open handler, Smile saves it as a droplet; otherwise it saves it as an applet. A droplet launches its open handler when the user drags a file or a folder or several of them on its icon.

When double-clicked, an applet launches the execution of its run (or unnamed) handler, then it quits. To have the applet remain open after having executed its run handler - which may be empty - choose Format ▸ Stay-open application when saving it to disk. An applet is itself a scriptable application: any script can call a running applet's handlers using the tell [...] end tell construct.

Saving a script without its source

The three last items in the Format menu of the Save dialog box are for saving the compiled script as run-only, that is, without retaining the source of the script. After you save with this option, you can no longer edit nor view the script: proceed with care and keep an editable copy.

Version française
Copyright ©2008 Paris, Satimage