The Following Script will not compile with the Applescript Editor:
tell application "iTunes"
set dialogTimeOut to 5
with timeout of ((dialogTimeOut + 1) * minutes) seconds
display dialog "Unrecoverable Error: Could not convert the MP3 filename from Unicode into a regular string." buttons {"Cancel"} default button "Cancel" with icon stop giving up after (dialogTimeOut * minutes)
end timeout
end tell
But if I change “with icon stop” to “with icon caution”, the script compiles just fine. Very strange.
Also note that if you move “with icon stop” to the end of the display dialog statement, the script will compile but when you run it, you get an error. The runtime error disappears when you change “with icon stop” to “with icon caution”.
Is this a bug in Applescript?
Rob
AppleScript: 1.10.7
Browser: Safari 419.3
Operating System: Mac OS X (10.4)
No it isn’t. It’s a dictionary clash: stop is a command in iTunes.
Within an application tell block the compiler takes first the dictionary of the targetted app.
The stop command in iTunes has no argument. This causes the “expected end of line.” error
As Stefan’s said, the compiler’s being fooled by a terminology clash between display dialog’s ‘stop’ constant and iTunes’s ‘stop’ command. Since you want iTunes to display the dialog, you can either use the icon’s numeric equivalent “ ‘icon 0’ “ instead or set a variable to the ‘stop’ constant before the iTunes ‘tell’ block:
tell application "iTunes"
set dialogTimeOut to 5
with timeout of ((dialogTimeOut + 1) * minutes) seconds
display dialog "Unrecoverable Error: Could not convert the MP3 filename from Unicode into a regular string." buttons {"Cancel"} default button "Cancel" giving up after (dialogTimeOut * minutes) with icon 0
end timeout
end tell
Or:
set theIcon to stop
tell application "iTunes"
set dialogTimeOut to 5
with timeout of ((dialogTimeOut + 1) * minutes) seconds
display dialog "Unrecoverable Error: Could not convert the MP3 filename from Unicode into a regular string." buttons {"Cancel"} default button "Cancel" giving up after (dialogTimeOut * minutes) with icon theIcon
end timeout
end tell
Great thanks for the reply. I still find it strange the the script will compile if the “with icon stop” is placed in particular places even though it should not compile at all (due to a dictionary conflict).
But now that I know the cause and a work around, I can be more confident that my script will work. I will just use “with icon 0” instead.