以下AppleScript按预期工作,为指定last played
中的第一首曲目提供user playlist
值。
tell application "iTunes"
set theTrack to (item 1 of tracks of user playlist "Named")
set playedDate to played date of theTrack
display dialog (playedDate as string)
end tell
然而,这个AppleScript不会编译,而是给我一个错误Expected end of line, etc. but found class name.
tell application "iTunes"
my testMethod(item 1 of tracks of user playlist "Named")
end tell
on testMethod(theTrack)
set trackName to (name of theTrack)
display dialog trackName
-- set playedDate to played date of theTrack
-- display dialog playedDate
end testMethod
这两个脚本是如此不同以至于AppleScript的编译器变得不稳定吗?如何在第二个示例中将played date of theTrack
传入playedDate
?
答案 0 :(得分:1)
played date
是iTunes
应用术语的一部分,您需要一个应用tell
块
tell application "iTunes"
set playedDate to played date of theTrack
end tell
或using terms from application
块,以帮助编译器解决术语
using terms from application "iTunes"
set playedDate to played date of theTrack
end using terms from
您现在可能会问:为什么name
有效?好吧,name
在许多应用程序中都是众所周知的属性,甚至AppleScript运行者都知道它。