I have written a script for Spotify with a subroutine
tell application "Spotify"
⋮
silentVolume(tmpDur)
⋮
end tell
on silentVolume(tmpDur)
tell application "Spotify"
⋮
set tmpDur to ((duration of current track) / 1000)
⋮
end tell
end silentVolume
Two problems with this
- When I call silentVolume with a float I get an error -1708 and the error message (translated to English so this is an approximation) "Spotify encountered an error. Cannot continue silentVolume". Why?
- silentVolume doesn't seem to inherit the context (tell application "Spotify") of the main function. Why?
Initially this subroutine was part of the main function and then it worked fine but I needed a recursive solution, therefore I had to break it out into a separate method.
⋮
in the code? They do not compile! What happens if you useset tmpDur to ((duration of current track) / 1000) as integer
, does it still throw an error?