开发者

AppleScript undefined variable

I know this is a quite simple script, but I keep getting an error message about an undefined variable. When I do, the result that is right before = "App Store" gets highlighted. I have tries rewriting that part of the script, but the same thing keeps happening. Can anybody notice a problem?

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 = "AppleSc开发者_运维知识库ript" 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


There is no need to nest all of those commands. Also, capture the result in a variable. So...

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


Try:

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

and for "App Store"

if answer is equal to "App Store" then

and for "More":

if answer is equal to "More" then
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜