Compile Error

I am making a simple program to control iTunes, here is the source code:

on clicked theObject
	tell application "iTunes" to activate
	tell application "iTunes"
		set playerState to player state
		
		if playerState is playing then
			playpause
		else
			set theTrack to current track
		        set contents of text field "SongTitle" to theTrack
		end if
	end tell
end clicked

The error I get is:
Building target “iTunes Test” of project “iTunes Test” with configuration “Debug” ” (1 error)
cd “/Users/dan/iTunes Test”
/usr/bin/osacompile -d -i /System/Library/Frameworks/AppleScriptKit.framework -U iTunes\ Test.applescript -o /Users/dan/iTunes\ Test/build/Debug/iTunes\ Test.app/Contents/Resources/Scripts/iTunes\ Test.scpt /Users/dan/iTunes\ Test/iTunes\ Test.applescript

/Users/dan/iTunes Test/iTunes Test.applescript:26: A " can’t go after this identifier. (-2740)

Command /usr/bin/osacompile failed with exit code 1

I have also tried this code for the track title:

set contents of text field "SongTitle" of window "iTunes Test" to theTrack

Thanks for the help,
Dan

Model: Macbook Pro
Browser: Firefox 1.5.0.7
Operating System: Mac OS X (10.4)

You have to be careful with what you put inside tell blocks; Your current code is probably trying to find a text field inside iTunes. (Also, you want the name of the current track, not a track object, and you need a full reference to the text field in your app.)

Try this instead:

on clicked theObject
	tell application "iTunes"
		launch
		set isPlaying to player state is playing
	end tell
	
	if isPlaying then
		tell application "iTunes" to playpause
	else
		tell application "iTunes" to set currentName to name of current track
		set contents of  text field "SongTitle" of window "iTunes Test" to currentName
	end if
end clicked theObject

Is that actually the only code in the script? What’s on line 26?

I would assume not, as the code he posted doesn’t contain any curly quotes like the one in the error message.