i don´t get what timeout really does. let´s say, copying of the file takes 59 seconds at most:
with timeout of 60 seconds
copy x to y
end timeout
what exactly happens.
is 60 seconds = 60 seconds (sounds stupid, but i wonder).
does the script wait for 60 seconds or does the timeout end, if the copying takes 10 seconds only?
in your code syntax the timeout block is useless.
It affects only Apple Events sent to applications.
The timeout block just watches the response of an Apple Event
tell application "iTunes"
if selection is not {} then
set sel to selection
with timeout of 300000 seconds
repeat with aTrack in sel
repeat with anArtwork in artworks of aTrack
if downloaded of anArtwork is true then
set theData to data of anArtwork
set data of anArtwork to theData
end if
end repeat
end repeat
end timeout
else
display dialog "Select some tracks first..." buttons {"Cancel"} default button 1 with icon 2 giving up after 15
end if
end tell
it takes very long. that´s the background of my question.
I mostly use it on display dialogs. By default, if the user leaves the dialog up for a bit without responding, the script will timeout. To prevent that you can wrap your display dialog line in a timeout of an hour or a couple of hours to keep the program from crashing.
Basically you would typically use it to override the default timeout (which essentially errors out your script) if something is taking a while.
Edit: In the dougscript above, the timeout is preventing the repeat loop from timing out if there are so many songs in the library that it would take a long time to repeat through them all.
Actually I use both a timeout and a giving up after. Got tired of timeout errors. Should the giving up after alone prevent the timeout error? I guess I never tried just that…
Airbuff, think of the timeout loop not as “make this last for 300000 seconds” but more as “it’s OK if this lasts for up to 300000 seconds so don’t throw an error”.