Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

AppleScript syntax

I know this is sloppy code, but here it is:

display dialog ("Start Screensaver. Please type: matrix, coffee, waffles, star, water, or
fireworks.", default answer "")
if text returned of result = "matrix" then
set user_choice to "MatrixSaver"
else
if text returned of result = "coffee" then
    set user_choice to "Coffee"
else
    if text returned of result = "waffles" then
        set user_choice to "Waffles"
    else
        if text returned of result = "star" then
            set user_choice to "Hyperspace"
        else
            if text returned of result = "water" then
                set user_choice to "LotsaWater"
            else
                if text returned of result = "fireworks" then
                    set user_choice to "Skyrocket"
                else
                    (*do nothing*)
                end if
            end if
        end if
    end if
end if
end if

if (user_choice = null) then (*do nothing*)
else
tell application "System Events"
    set ss to screen saver user_choice
    start ss
end tell
end if

When I'm trying to compile my code, the 'default answer' Is highlighted, and it says: "Expected “)”, etc. but found identifier."

Any Ideas? Thanks.

like image 522
CodeKid Avatar asked Mar 16 '26 21:03

CodeKid


1 Answers

I believe the correct syntax is just

display dialog "Start Screensaver. Please ..." default answer ""
like image 53
jtbandes Avatar answered Mar 18 '26 11:03

jtbandes



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!