AppleScript初学者,并且仍在努力学习基本语法。
这有效:
tell application "Mail"
set flagged to messages of inbox whose flagged status is true
log count of flagged
end tell
这不起作用:
tell application "Mail"
set msgs to messages of inbox
set flagged to msgs whose flagged status is true
log count of flagged
end tell
为什么呢? (我怀疑这是一个逃避我的简单的句法规则)
答案 0 :(得分:2)
当你写set msgs to messages of inbox
时,你真正说的是set msgs to GET messages of inbox
,因为AppleScript会自动执行get
命令,如果你不这样做,其结果是AppleScript列表(消息引用),例如:
{message id 123 of mailbox "Inbox" ..., message 124 of mailbox "Inbox" ...}
但是,whose
查询(引用)仅适用于应用程序对象,而不适用于AppleScript列表,例如:
every item of {1, 2, 3, 4, 5} where it > 3
-- error "Can’t get {1, 2, 3, 4, 5} whose it > 3." number -1728
请尝试以下方法:
tell application "Mail"
set msgs to a reference to messages of inbox
set flagged to msgs whose flagged status is true
log count of flagged
end tell