2013-03-30 6 views
-1

я сделал делал это AppleScript для запуска приложений с пометкой:Переменная не определена - Applescript

tell application "Notes" 
if exists note starts with applaunch then 
    set LCommands to {"Launch", "Open"} 
    repeat with y from 1 to count LCommands 
     set applaunch to (item y of LCommands) 
     set AppleScript's text item delimiters to applaunch 
     set myApp to text items 2 thru 1 of note 
     set AppleScript's text item delimiters to {""} 
     set myApp to myApp as text 
     if y = 1 or y = 2 then 
      tell application myApp to launch 
     end if 
    end repeat 
    delete note starts with applaunch 
end tell 

и возвращает ошибку «переменная applaunch не определена», но я определил его. что делать?

ответ

0

Вы ссылку applaunch в строке 2, но вы никогда не определите его до линии 5.

Кроме того, ваш пример кода отсутствующей в end if, который идет с if exists note starts with applaunch then.

0

Вы можете попробовать что-то вдоль этих линий:

set LCommands to {"Launch ", "Open "} 

tell application "Notes" 
    repeat with aCommand in LCommands 
     set aCommand to (contents of aCommand) 
     set myNotes to (notes whose name begins with aCommand) 
     repeat with aNote in myNotes 
      set aNote to contents of aNote 
      set noteName to aNote's name 
      set AppleScript's text item delimiters to aCommand 
      set myApp to text items 2 thru -1 of noteName 
      set AppleScript's text item delimiters to {""} 
      set myApp to myApp as text 

      -- If you need to work with the Note's content as plain text 
      --set noteBody to do shell script "echo " & (quoted form of (aNote's body as text)) & " | textutil -stdin -convert txt -stdout " 
      my launchDelete(aNote, myApp) 
     end repeat 
    end repeat 
end tell 

on launchDelete(theNote, theApp) 
    try 
     tell application theApp to launch 
     tell application "Notes" to delete theNote 
    end try 
end launchDelete 
Смежные вопросы