Section 2.3. Setting Script Editor s Preferences


2.3. Setting Script Editor's Preferences

Now that you've been using Script Editor for a little while, the boring text coloring is probably starting to get to you. Or maybe you're just sick of reading your scripts in a 12-point font. No matter what your complaint, chances are Script Editor can make things better for you.

Start out by opening Script Editor Preferences (-,). You'll see five buttons in the toolbar, each for a different aspect of Script Editor's behavior. Click the category you want to customize (Figure 2-8), and continue reading.

Figure 2-8. Script Editor's Preferences window. Click a toolbar button to jump right to that particular pane.


2.3.1. General

Fresh out of the box, your Mac comes with only one language you can use in Script Editor: AppleScript. That's why Script Editor automatically understands your AppleScript commands when you create a new script and click Run.

However, some people install other programming languageslike JavaScriptfor use in Script Editor (Sidebar 3.2), and that's where the Default Language pop-up menu comes in. With this menu, you can select what language you want to use for all new scripts. (If you ever want to override this setting for a single script, just use the Navigation Bar [Sidebar 2.4].)

2.3.2. Editing

The three sections of the Editing pane allow you to customize how text appears in Script Editor's windows. The Line Wrap preferences, for example, let you set whether text that's too long for one line continues onto the next one (Wrap Lines on) or scrolls off the side of the window (Wrap Lines off). If you've turned Wrap Lines on, you can even set how many space-widths the overflowing lines are indented.

The Tabs section, on the other hand, let you choose whether your script should be indented at all. If you turn off "Editor uses tabs," all your commands will end up flush against the left side of the Script Field. (Or, at least that's the idea; as of Mac OS X v10.3, this setting worked so inconsistently that it was pretty much useless.)

Finally, turning on the Script Assistant enables Script Editor's secret autocomplete feature. With the Script Assistant, you don't have to remember the full names for AppleScript commands; you just type the first few letters, and the Assistant does the rest (Figure 2-9).

Figure 2-9. Top: Once Script Assistant is turned on, you can just type the first letter of an AppleScript keyword. Script Editor presents you with its best guesses to finish the word.Middle: If you type the next letter of the word, Script Assistant narrows down the possibilities. In this case, there's only one keyword that starts with "ap," so Script Editor fills it in lightly. Bottom: Press Option-Escape to confirm that you want to use Script Assistant's suggestion. (If you don't want to use its suggestion, simply keep typing.) Using Script Assistant, you can cut your actual typing time in half.


2.3.3. Formatting

If you're bored with Script Editor's coloring scheme, this is the preference pane for you. Simply select the kind of text you want to customizeLanguage keywords, for exampleand then double-click the little color swatch to open the Color palette and change its color. (If you'd like, you can also double-click an item's Font entry to change its font.) Figure 2-10 shows one possibility.

As you go through the types of text, modifying them to your liking, the Category column updates itself with the fonts' new look. Click Apply to make your changes take effect, or click Revert to go back to the previous settings.

The fonts you set in Script Editor are also the ones used for AppleScript commands in Xcode (Section 14.5).

Figure 2-10. The default fonts are easy to read but not much fun to look at (left). After a little tweaking in the Formatting pane, you can make your code hard to read but more fun to look at (right). To reset the fonts, click Use Defaults in the Formatting pane.


2.3.4. History

When you choose Window Result History (Option--R), you see a list of the results from the past few scripts you've run. You can set how many results are listed there by changing the "Maximum entries" setting in the History pane of Script Editor's preferences.

If you run a lot of scripts, you can even set the History to display "Unlimited entries," meaning that the Result History window will show every single script's results since you last launched Script Editor.On the other hand, if you don't care what your scripts' results are, you can just turn off the Enable Result History checkbox altogether.

You can set the same preferences for the Event Log History, too (Section 14.2.2).

2.3.5. Plug-ins

Script Editor is useful on its own, but there are plug-ins to add even more features (such as those available from the Web sites listed on Section C.1). For example, the HetimaOsaxOpener plug-in adds a new item to the File menu for opening any scripting additions you have installed on your Mac (Sidebar 3.5). Here's how you'd install this plug-in:

  1. Quit Script Editor.

    You should always quit a program (-Q) before installing new plug-ins for it.

  2. Download the plug-in you want.

    HetimaOsaxOpener, for instance, is available from http://hetima.com/soft/hetimaosaxopener.html.

  3. Drag the plug-in into the Library Application Support Apple Script Editor folder.

    If the folder doesn't exist already, create it yourself.

    If don't want other users of your computer to have access to the plug-in, drag it to your Home Library Application Support Apple Script Editor folder.

  4. Relaunch Script Editor.

    If you installed the plug-in correctly, you should see a confirmation dialog box. Click Enable.

  5. Choose Script Editor Preferences Plug-ins.

    The new plug-in appears in the list here. (You'll also see the new Open OSAX item in the File menu.)

If you ever want to disable a plug-in, just turn off its checkbox in the Plug-in preferences, and relaunch Script Editor.

Power Users' Clinic
Other AppleScript Editors

Script Editor is great for writing AppleScript commands, and every script in this book works just fine with it. Like most features in Mac OS X, however, there are alternatives to Script Editor that pack more power:

  • Smile (free), from Satimage Software, is a nice alternative to Script Editor that packs a few extra features. Smile includes a more powerful Find feature than Script Editor, for example, and lets you quickly locate the definition of any AppleScript keyworda great timesaver. You can even step through scripts line by line, to test how each command works. To download Smile, visit http://www.satimage.fr/software/en/downloads_software.html.

  • Script Debugger ($190), from Late Night Software, is an amazingly powerful, full-featured script editor. You'll find just about everything you could dream of: incredible customizability, tons of convenient keyboard shortcuts, and the ability to run individual lines at your leisure. If you spend a lot of time with AppleScript, Script Debugger (www.latenightsw.com/sd3.0/index.html) can make your work much easier.

  • Xcode (free) is Apple's souped-up programming tool, the main attraction of the Xcode Tools. It has line numbering, great search capabilities, and the ability to pause commands, among other powerful features. See Section 14.5.1 for instructions on installing and using the Xcode Tools.

In addition to these programs, you can write scripts in just about any text editor you want. As long as you save the files as plain text (Section 2.2.3) and use the osascript command in the Terminal to run them (Section 13.4), you can use programs like TextEdit and BBEditor even Unix editors like pico and vi (Section 13.1.2)to write AppleScripts.




AppleScript. The Missing Manual
AppleScript: The Missing Manual
ISBN: 0596008503
EAN: 2147483647
Year: 2003
Pages: 150

Similar book on Amazon

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net