2 Replies Latest reply: Mar 2, 2013 5:46 AM by HD
Mac Maker227 Level 1 Level 1 (0 points)

I am trying to make this app:

 

display dialog "Open Which Application" buttons {"Chrome", "AppleScript", "Textedit"}

set the button_pressed to the button returned of the result

if the button_pressed is "Chrome" then

Open application "Google Chrome"-- action for 1st button goes here

if the button_pressed is "Applescript" then

Open application "Applescript Editor"-- action for 2nd button goes here

if the button_pressed is "Textedit" then

Open application "Textedit"-- action for 3rd button goes here

end

 

But it keeps saying SYNTAX ERROR: expected else ect but found end of script/line

 

What do I do????

  • 1. Re: Syntax error on applescript
    John Maisey Level 5 Level 5 (6,880 points)

    Hi,

     

    In your 'if' block conditional syntax subsiquent options should be formatted as  'else if':

     

    display dialog "Open Which Application" buttons {"Chrome", "AppleScript", "Textedit"}

    set the button_pressed to the button returned of the result

    if the button_pressed is "Chrome" then

      open application "Google Chrome" -- action for 1st button goes here

    else if the button_pressed is "Applescript" then

      open application "AppleScript Editor" -- action for 2nd button goes here

    else if the button_pressed is "Textedit" then

      open application "TextEdit" -- action for 3rd button goes here

    end if

     

    Best wishes

    John M

  • 2. Re: Syntax error on applescript
    HD Level 4 Level 4 (3,240 points)

    "open application" won't work either, as far as I'm aware. The syntax is

     

    tell application "Google Chrome" to activate