AppleScript列表和WHERS子句

AppleScript列表和WHERS子句,applescript,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 w

这里是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

为什么??(我怀疑这是一个简单的语法规则,我不明白)

当你写
设置msgs到收件箱的消息时,你真正要说的是
设置msgs到收件箱的消息
,因为AppleScript会自动执行
GET
命令,如果你不告诉它,结果就是AppleScript列表(指消息引用),例如:

但是,
查询(引用)仅适用于应用程序对象,而不适用于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

当您编写
set msgs to messages of inbox
时,您真正要说的是
set msgs to GET messages of inbox
,因为如果您不告诉它,AppleScript会自动执行
GET
命令,其结果是一个AppleScript列表(邮件引用),例如:

但是,
查询(引用)仅适用于应用程序对象,而不适用于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