2016-10-03 14 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 

なぜ?あなたがset msgs to messages of inboxを書くとき、あなたが、そうでない場合の結果を、それを教えていない場合はAppleScriptが自動的getコマンドを実行して、何が本当に言っていることはset msgs to GET messages of inboxある

答えて

2

(私はそれが私を脱出される単純な構文規則だ疑いがあります) (メッセージ参照の)の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