View Full Version : Quick newbie AppleScript question

Oct 7, 2005, 07:47 PM
I'm trying to place a variable within a sentence. Here's an example:
display dialog "What is your name?" default answer "" buttons {"Cancel", "Okay"} default button 2
copy the result as list to {theText, theButton}
if theText contains "My name is" then
set fourthWord to word 4 of theText
display dialog "My name is -this is where the variable should be!- too!"
end if
How can I have the variable fourthWord inserted in the middle of that quote? I've looked how to do it everywhere and I'm stumped :confused:
I'd greatly appreciate someone's help.

Oct 8, 2005, 04:50 AM
In AppleScript & is the concatenation operator. So your line should be something like:

display dialog "My name is " & fourthWord & " too!"

If you want an AppleScript book I'd recommend AppleScript The Definitive Guide (O'Reilly). This is on page 279!

Oct 8, 2005, 12:11 PM
Thanks a bunch! That will be the next book I buy:)