Chapter 4. Manipulating Text


Since the ancient days of DOS, text has always played an important role in computing. Even today, 20 years after the first Mac came out, every computer Apple ships comes with a keyboard. What's more, Mac OS X's Unix core is strictly based on text: preference files are in plain text, and the commands you issue in Terminal (Section 13.1) are all, well, text.

The importance of text isn't lost on AppleScript, though. From its dialog box capabilities to the Text Suitea standard set of AppleScript keywords that deals with the details of words, characters, and paragraphs (Section 4.6.1)AppleScript handles text the way Mac OS X does: simply and powerfully. For example, you can harness AppleScript's text mojo to do things like:

  • Add a word count feature to TextEdit (Section 4.6)

  • Shrink all the fonts in a document simultaneously (Section 4.7.2)

  • Type and run AppleScript commands in just about any programnot just Script Editorusing an application's Services menu

AppleScript's text features are quite powerful, but they're not always easy to learnespecially if you're reading Apple's geeky help files. Thankfully, you don't have to; just continue reading this chapter instead.

The example scripts from this chapter can be found on the AppleScript Examples CD (see Sidebar 2.1 for instructions).



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

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