Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

phreakout13

macrumors 6502
Original poster
Jan 4, 2004
317
0
South Eastern MA
Hello:)
I'm trying to place a variable within a sentence. Here's an example:
Code:
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.
Thanks:)
 

robbieduncan

Moderator emeritus
Jul 24, 2002
25,611
893
Harrogate
In AppleScript & is the concatenation operator. So your line should be something like:
Code:
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!
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.