Неопределенная переменная AppleScript - PullRequest
0 голосов
/ 16 августа 2011

Я знаю, что это довольно простой скрипт, но я получаю сообщение об ошибке с неопределенной переменной. Когда я это сделаю, подсвечивается result прямо перед = "App Store". Я пытаюсь переписать эту часть сценария, но происходит то же самое. Кто-нибудь может заметить проблему?

say "Welcome, Master Daniel. It is currently"
say time string of (current date)
say "All systems are operational. Would you like to open an application?"
display dialog "Open An Application." buttons ["Mail", "App Store", "More"]
if button returned of result = "Mail" then
tell application "Mail"
    activate
end tell

if button returned of result = "App Store" then
    tell application "App Store"
        actvate
    end tell

else (* do nothing *)
end if
else (* do nothing *)
end if

if button returned of result = "More" then
display dialog "Open An Application." buttons ["Safari", "iTunes", "AppleScript"]

if button returned of result = "Safari" then
    tell application "Safari"
        activate
    end tell

    if button returned of result = "iTunes" then
        tell application "iTunes"
            activate
        end tell

        if button returned of result = "AppleScript" then
            tell application "AppleScript Editor"
                activate
            end tell

        else (* do nothing *)
        end if
    else (* do nothing *)
    end if
else (* do nothing *)
end if
else (*do nothing*)
end if

Ответы [ 2 ]

1 голос
/ 16 августа 2011

Нет необходимости вкладывать все эти команды. Также запишите результат в переменную. Итак ...

display dialog "Open An Application." buttons ["Mail", "App Store", "More"]
set the button_pressed to the button returned of the result

if button_pressed = "Mail" then
    tell application "Mail"
        activate
    end tell
end if

if button_pressed = "App Store" then
    tell application "App Store"
        activate
    end tell
end if
0 голосов
/ 16 августа 2011

Попробуйте:

set question to display dialog "Open An Application." buttons ["Mail", "App Store", "More"]

set answer to button returned of question

if answer is equal to "Mail" then

и для "App Store"

if answer is equal to "App Store" then

и для «Больше»:

if answer is equal to "More" then
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...