Looks like no one’s replied in a while. To start the conversation again, simply ask a new question.

Use a variable in AppleScript

Hello,


I'm a very beginner in AppleScript and I juste want to test some functions to include in Automator.


So, for example, I want to pass a track in a fonction to get the played count.


Here is my script :

on run {input, parameters}

  set t to input
  set currentCount to getCount(t)

  return currentCount
end run


on getCount(t)

  tell application "iTunes"
  set currentCount to played count of t
  end tell

  return currentCount

end getCount


But I have an error and my script doesn't work, it seems I can't use "played count of t".


What's wrong ? Thx for your help.

Posted on Apr 20, 2015 9:46 AM

Reply
Question marked as Best reply

Posted on Apr 22, 2015 9:00 AM

Hi,


Because the input variable contains a list, use item 1 of input to get the first element.


on run {input, parameters}
    tell application "iTunes" to return played count of (item 1 of input)
end run
1 reply

Use a variable in AppleScript

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple ID.