2016-07-27 15 views
0

私はまったくばかげた問題を抱えています。 plistファイルのノードにアクセスする必要があります。問題がある場合は、ダイアログに「停止」アイコンが表示されます。ここでは、コードです:それは大胆な青いフォントでだからアイコンストップ&システムイベントのApplescriptと表示ダイアログ

tell application "System Events" 
    tell property list file (plistFile as text) 
     try 
      tell contents 
       set backupDayTemp to value of property list item plistElementBackupDay of property list item chosenBackupDisk 
      end tell 
     on error m number n from f to t partial result p 
      if n = -1728 then 
       display dialog "Can't find " & plistElementBackupDay & " key for disk " & chosenBackupDisk & " in plist file." buttons {"Damn", "Oh dear"} default button "Damn" with title myName with icon stop 
       return 
      else 
       -- otherwise, pass the error on 
       error m number n from f to t partial result p 
      end if 
     end try 
    end tell 
end tell 

コンパイラはシステムイベントは、トークンが「停止」を理解するべきものであると考えているようだが、ない紫色のイタリック体は、それが正常であること、いつであろうと。エラーハンドラが実行されました。「システムイベントにエラーがあります:プロパティリストファイル[パス]が「停止」メッセージを理解していません。

私の質問は、トークンがそれではないことをシステムイベントにどのように伝えますか?私はの前にtell me toを置こうとしましたが、それは助けになりませんでした。私もusing terms from application "Standard Additions"を試しましたが、実行するとStandard Additionsの辞書を探すよう求められます。

私の髪を引き裂く!

+0

のtellアプリケーションは、「Finderは」ダイアログを表示するようにブロック伝えるアプリケーションのうち、エラー処理を置くことです、あなたのアプリケーションの焦点をFinderに変更するということです。 – pbell

答えて

0

最も簡単な解決策は、もちろん、除いて、あなたの問題を解決し、アイコンストップで....

try 
    tell application "System Events" 
     tell property list file (plistFile as text) 
      tell contents 
       set backupDayTemp to value of property list item plistElementBackupDay of property list item chosenBackupDisk 
      end tell 
     end tell 
    end tell 
on error m number n from f to t partial result p 
    if n = -1728 then 
     display dialog "Can't find " & plistElementBackupDay & " key for disk " & chosenBackupDisk & " in plist file." buttons {"Damn", "Oh dear"} default button "Damn" with title myName with icon stop 
     return 
    else 
     -- otherwise, pass the error on 
     error m number n from f to t partial result p 
    end if 
end try 
+0

ありがとう...最後に、私は絶望的になり、私が呼び出したハンドラに 'display dialog'を入れました。私はエラー処理をさらに進めたいとは思っていませんでしたが、おそらくそうでない理由はないと受け入れています。 – skiaddict1

関連する問題