5

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

  1. 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?
  2. 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.

3
  • What's with the four occurrences of vertical dots in the code? They do not compile! What happens if you use set tmpDur to ((duration of current track) / 1000) as integer, does it still throw an error? Sep 29, 2017 at 16:22
  • It was just a vertical replacement for an ellipsis (…) you can use to indicate that something was left out.
    – d-b
    Sep 29, 2017 at 21:07
  • @user3439894 It fails already on the tell-statement in the subroutine.
    – d-b
    Sep 29, 2017 at 21:08

1 Answer 1

6

It was a problem with the scope. This question got me on the right way. I needed to change the call to the subroutine to

my silentVolume (tmpDur)

and then now works as expected. Leave it here as a future reference for anyone googling error -1708.

1
  • You should consider mark your own answer as the correct answer. And thanks by the way.
    – ePi272314
    Dec 5, 2018 at 0:28

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .