2016-10-03 76 views
1

AppleScript初学者在这里,仍然苦于基本的语法。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 

为什么? (我怀疑它是在逃避我一个简单的语法规则)

回答

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