what is wrong with the following script?
i get the error: “NSReceiverEvaluationScriptError: 4(1)”
i don’t understand why! i’ve isolated the problem to the lines of code that say: “set contents of text view 1 of window “lyric” to (new_clean_text as string)” or something like that
my code is as follows:
on remove_markup(this_text)
log "Started cleaning text"
set myAllowed to {"://", "@"}
set {myTID, AppleScript's text item delimiters} to {AppleScript's text item delimiters, {"<"}}
set these_items to text items of this_text
set AppleScript's text item delimiters to {">"}
repeat with my_item in these_items
if length of text items of my_item is greater than 1 then
if (text item 1 of my_item) is not in myAllowed then
set my_item's contents to (text item 2 of my_item)
else
set my_item's contents to ("<" & (text items of my_item)) as text
end if
end if
end repeat
set AppleScript's text item delimiters to myTID
set clean_text to these_items as text
--return clean_text
log "Text Cleaned"
set new_clean_text to ""
set y to 0
repeat with lin in clean_text
set num to (ASCII number of lin)
if y is 12 then
--log "y is 6"
set new_clean_text to new_clean_text & (ASCII character of num)
else
set y to (y + 1)
--log y
end if
end repeat
log "Removed first 12 lines"
set contents of text view 1 of window "lyric" to (new_clean_text as string)
end remove_markup
on clicked theObject
tell application "iTunes"
set artis to artist of current track
set nam to name of current track
end tell
set ur to "http://www.azlyrics.com/lyrics/"
set new_artis to ""
set new_nam to ""
repeat with char1 in artis
set num1 to (ASCII number of char1)
if num1 is greater than 62 and num1 is less than 91 then set num1 to (num1 + 32)
if num1 is greater than 47 and num1 is less than 58 then set new_artis to new_artis & (ASCII character of num1)
if num1 is greater than 96 and num1 is less than 123 then set new_artis to new_artis & (ASCII character of num1)
end repeat
repeat with char2 in nam
set num2 to (ASCII number of char2)
if num2 is greater than 62 and num2 is less than 91 then set num2 to (num2 + 32)
if num2 is greater than 47 and num2 is less than 58 then set new_nam to new_nam & (ASCII character of num2)
if num2 is greater than 96 and num2 is less than 123 then set new_nam to new_nam & (ASCII character of num2)
end repeat
set new_url to (ur & new_artis & "/" & new_nam & ".html") as string
log new_url
set myHtml to do shell script "curl " & new_url
log "Curled url"
set {myDels, AppleScript's text item delimiters} to {{""}, {"</head>"}}
try
set myText to text item 2 of myHtml
set AppleScript's text item delimiters to myDels
log "Starting Remove_markup"
set myText to remove_markup(myText)
--remove_markup()
on error err
log "Lyrics not found"
set contents of text view 1 of window "lyric" to ("Lyrics not found" as string)
display dialog err
end try
--remove_markup()
end clicked
also, what is the difference between a “text view” and a “scroll view”?
thxs