Hi all!
Applescript newbie here, so this is probably rudimentary:
I’ve done an iTunes script which involves frequent timechecks to determine if it is time to switch playlists. The script is working as I want, but I now want to replace all the repeated time checks with handlers (one for each “time profile”), so that if I want to change the intervals, I need only to change the handler. My handlers are simple and look like this:
on checkTime()
if (hours of (current date)) ≤ 8 or (hours of (current date)) ≥ 15 then
exit repeat
end if
end checkTime
I then call that handler within my script with a:
checkTime() of me
command (the “of me” part being because it is inside a “tell application” script)
When the if-statment is true, Applescript returns an error about the closing message not being a repeated loop (unsure of the exact english phrasing, I’m on a foreign version). My layman theory is that this is because the handler involves the exiting of a repeat-loop that is defined outside the handler? I would need to have it this way though, because that repeat-loop also consists of a number of other commands and instructions that I don’t want confined in my handler.
Basically, all I need is a way to have Applescript read those three lines of code everytime I enter a simple replacing command. I thought that a handler would be the way to do this, but I can’t get it to work. Any help is greatly appreciated!
Thanks,
Erik