By Adam Goldstein
Book Price: $24.95 USD
£17.50 GBP
PDF Price: $16.99
Cover | Table of Contents | Colophon
-drag its icon farther to the right.
-,).
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.
display dialog "Hello! I'm your first AppleScript."
tell application "Finder"
activate
open home
end tell
"Yam farmer" "5504.45" "What the *#@&?!"
"Yam farmer" "5504.45" "What the *#@&?!"
set welcomeMessage to "Take your shoes off before entering the building."
set welcomeMessage to "Take your shoes off before entering the building."
display dialog welcomeMessage
display dialog "Enter your name:" default answer "Sylvester"
set userResponse to the text returned of (display dialog "Enter your name:" ¬
default answer "Sylvester")
display dialog userResponse
set ¬ userResponse ¬ to the text returned ¬ of (display dialog ¬ "Enter your name:" ¬ default answer "Sylvester") display dialog userResponse
&
), which tells
AppleScript to "put together the strings on my left
and right." Here's what the
improved script would look like:set userResponse to the text returned of (display dialog "Enter your name:" ¬
default answer "Sylvester")
set theGreeting to "Hey, " & userResponse & "!"
display dialog theGreeting
set multiLiner to "To whom it may concern,\nI want my money back.\nThanks." display dialog multiLiner
set multiLiner to "To whom it may concern, I want my money back. Thanks" display dialog multiLiner
-O), scroll down to TextEdit, and
click Open. As you can see from the left pane of Figure 4-4, TextEdit has a rather lengthy—and quite
detailed—dictionary. Take the time to peruse all the scripting
suites now, so you can get a feel for what AppleScript and TextEdit
can do together.tell application "TextEdit"
activate
--Count the characters:
set allCharacters to every character of the front document
set numberOfCharacters to (count allCharacters)
set characterText to "Characters: " & numberOfCharacters
--Count the words:
set allWords to every word of the front document
set numberOfWords to (count allWords)
set wordText to "Words: " & numberOfWords
--Count the paragraphs:
set allParagraphs to every paragraph of the front document
set numberOfParagraphs to (count allParagraphs)
set paragraphText to "Paragraphs: " & numberOfParagraphs
--Assemble the text for the dialog box:
set dialogText to characterText & return & wordText & return ¬
& paragraphText
display dialog dialogText
end tell
tell application "Microsoft Word"
activate
. . .
end tell
tell application "Finder"
activate
open the folder "Users:yourUsername:Music"
open the folder "Users:yourUsername:Pictures"
end tell
tell application "Finder"
move someItem to somePlace
end tell