Writing and editing scripts

    Whether you start with an existing script, record actions, or write your own script, you will need to edit your script using the Script Editor. You use the Script Editor to write and edit scripts in the same way you use other text editors.

Breaking up a line

    You can use the continuation character (¬) to break up long lines in a script. When you run the script, AppleScript treats the line as a single line. Here's an example:

    make new folder at desktop with properties ¬
    {name:"My Folder", label index:0, selected:true, ¬
    comment:"A folder for my new files!"}

    To insert a continuation character in a line:
    Press Option and Return.

Indenting lines

    As you write a script, the Script Editor can indent the lines of compound statements to show their structure.

    To indent lines in a compound statement:
    Press Return at the end of each line.

Formatting the script

    When you check the syntax of a script, the Script Editor formats the different types of terms in the script. You can change the way it formats the script.

    To change script formatting:
    1 Open the Edit menu and choose AppleScript Formatting.
    2 Click an item in the list, then use the Font and Style menus to choose how to format it.

    The changes you make apply to any script you open. You cannot format part of a script. You can format text in the Description field.

 


Table of contents