Although you will not learn how to interact with and automate Mac OS X applications until Chapter 8, “Automating Mac OS X Applications,” I thought I’d go ahead and show you how to use the TextEdit application to print text files that you generate with your AppleScripts. TextEdit is a free text editing Mac OS X application supplied as part of the operating system.
To interact with and control the TextEdit application, you will need to use the tell command to set up a code block in which you will embed commands that you want AppleScript to pass along to TextEdit for processing, as demonstrated here:
tell application "TextEdit" print (path to desktop folder as string) & "GroceryList.txt" end tell
Here, TextEdit’s print command ...