how come this won't compile?

Ok, so my script gets lyrics from a website, and then iwant them to appear in a scrollview/text view thing.
this is my code:

on idle theObject
	using terms from application "iTunes"
tell application "iTunes"
set cur_track to the name of the current track as string
set cur_artist to the artist of the current track as string
set theSong to cur_track
set theArtist to cur_artist

set theSong to lowercase(theSong)
set theArtist to lowercase(theArtist)


set ASTID to AppleScript's text item delimiters
set AppleScript's text item delimiters to {" "}
set theSong to text items of theSong
set theArtist to text items of theArtist

set AppleScript's text item delimiters to {"-"}
set theSong to theSong as Unicode text
set theArtist to theArtist as Unicode text
set AppleScript's text item delimiters to {""} -- Not really needed here, but we're not using any error handling on the shell script, so.

get "http://www.lyricsdir.com/" & theArtist & "-" & theSong & "-lyrics.html"
do shell script "/usr/bin/curl --user-agent '' " & quoted form of result
set theLyrics to result

set AppleScript's text item delimiters to {"<div id=\"lyrics\">"}
set theLyrics to (last text item of theLyrics) as Unicode text

set AppleScript's text item delimiters to {"</div>"}
set theLyrics to first text item of theLyrics

set AppleScript's text item delimiters to {"<br />"}
set theLyrics to text items of theLyrics

set AppleScript's text item delimiters to {""}
set theLyrics to text 2 thru -1 of (theLyrics as Unicode text) -- removes a newline

-- proper way to set the delimiters back (that's why you "saved" them earlier!)
set AppleScript's text item delimiters to ASTID

tell window "mainWindow"
set the contents of text view "lyrics_text" of scroll view "lyrics_box" to theLyrics--this is where i get the error.
end tell

on lowercase(someText)
	return do shell script "/usr/bin/python -c \"import sys; print unicode(sys.argv[1], 'utf8').lower().encode('utf8')\" " & quoted form of someText
end lowercase
end idle

You don’t seem to close (end) these lines:

using terms from application "iTunes" -- I don't think you even need to use this
tell application "iTunes"

Also, the lowercase handler needs to be outside of the on idle handler.

Side note: You don’t have to use as string for things that already return a string:

set cur_track to the name of the current track as string -- you don't need `as string` here

Another side note: What happens if there isn’t a current track in iTunes?

actually what it was (besides what you said) was the fact that i didn’t have just as the script itself. I only had it in the idle, so it didn’t work but once i put it in well…no handlers then the idle handler it works. BTW is there anyway, i could like…ok…the script gets the name and artist of the current song in iTunes, but takes out everything that isn’t a letter or number…i have already converted the spaces so they become hyphens but i want other punctuation to become just nothing…like just remove it.

Here’s one way you could do that:

set theSong to lowercase(theSong)
set theArtist to lowercase(theArtist)

-- Add these two lines
set theSong to removeStuff(theSong)
set theArtist to removeStuff(theArtist)

-- Add this handler somewhere
on removeStuff(someText)
	-- Remove anything that is not alphanumeric or a space
	return do shell script "echo " & quoted form of someText & "/usr/bin/ruby -ne 'print $_.delete(\"^a-z\", \"^A-Z\", \"^0-9\", \"^ \")'"
end removeStuff