AppleScript Mode Help
Name:AppleScript Mode
Version:2.5
Last update:2020-05-27 14:28:45





Introduction

AppleScript mode is a mode for the text editor Alpha: it is designed to facilitate editing and processing of scripts written in the AppleScript language, with all the powerful editing facilities provided by Alpha.
Once you are in AppleScript mode, there is a new menu (represented by the AppleScript editor icon) in the menu bar giving access to all the features described below.
AppleScript mode processing features rely on the Tclapplescript extension which interacts directly with the MacOS Open Scripting Architecture. You do not have to install it on your machine: it is included in Alpha's bundle. Note that the AppleScript Editor application does not have to be launched or even present on your computer for this mode to work.

The AppleScript menu

Here is the description of the AppleScript menu items:
New Script
Open a new editing window in AppleScript mode. This does not create a file on disk until you save the window.
Run The Buffer
Run the script edited in the current document window (or only the selection if there is one). The result is sent to a separate AppleScript Results window.
Run A Script…
Brings up a dialog to select a compiled script and run it. The result of the excution is sent to a separate AppleScript Results window.
Decompile A Script…
Brings up a dialog to select a compiled script: the script is decompiled and edited in a new window in AppleScript mode.
Line Continuation
Insert a line continuation symbol (¬) which is not always easy to find on the keyboard, especially on international keyboards. The symbol is inserted at the end of the current line.
Add Description
Insert a special comment at the beginning of the edited script to give a description the script.
Delete Description
If the Option key () is pressed, the item Add Description is changed to Delete Description in order delete the descriptive comment from the edited script.
AppleScript Bindings
Display the key bindings available in AppleScript Mode.
AppleScript Tutorial
Open the AppleScript Mode tutorial in a shell window.

The Mark pop-up menu

The marking procedure marks all the function definitions (aka handlers in AppleScripts parlance), i-e all the statements of the form:
 on functionName(params)
     -- instructions
 end functionName
where functionName designates the name of handler. The error statements (on error etc.) are not marked though by the procedure since they do not correspond to function definitions.

The Functions pop-up menu

The Functions pop-up menu also displays the handlers defined in the current window.

Completions

There is a set of completion procedures in AppleScript mode.
All AppleScript keywords can be completed. Type the first letters of an AppleScript keyword and hit the completion key. If it is recognized as a keyword, it will be automatically completed. If there are different possibilities, a listpick dialog is displayed to choose the one you want.
There is also a set of electric abbreviations. Just type any of the following words and hit the completion key to have them expanded to a complete structure: For instance tell will result in:
    tell application "•"
        •
    end tell

Key bindings

A few mode specific key bindings are defined in AppleScript mode.
In order to execute the script contained in the current document window, press ⌘T.
Other bindings are composite. They use the combination 'ctrl-a' (⌃A) followed by a letter. For instance, to decompile and edit a script, hit 'ctrl-a' and then the letter 'd'. The following bindings are available:
⌃A Bto display the info about bindings
⌃A Dto decompile and edit a script
⌃A Lto insert the line continuation symbol (¬)
⌃A Nto create a new script
⌃A Rto select and run a script

AppleScript Mode preferences

The menu item Alpha ↣ Mode Setup ↣ Mode Preferences… allows you to edit mode-specific preferences.
Click here to open the AppleScript Mode preferences panel.

Known problems

Please report any problem or bug you encounter to Alpha's Bug Tracker.

License and Disclaimer

Copyright (c) 2002-2020, the Alpha Community.
All rights reserved.
The AppleScript Mode package is free software and distributed under the terms of the new BSD license:
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE ALPHA COMMUNITY BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.