Looks like no one’s replied in a while. To start the conversation again, simply ask a new question.

Syntax error on applescript

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????

Posted on Mar 1, 2013 3:24 PM

Reply
Question marked as Best reply

Posted on Mar 1, 2013 5:48 PM

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


openapplication "Google Chrome" -- action for 1st button goes here

else if the button_pressed is "Applescript" then


openapplication "AppleScript Editor" -- action for 2nd button goes here

else if the button_pressed is "Textedit" then


openapplication "TextEdit" -- action for 3rd button goes here

end if


Best wishes

John M

2 replies
Question marked as Best reply

Mar 1, 2013 5:48 PM in response to Mac Maker227

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


openapplication "Google Chrome" -- action for 1st button goes here

else if the button_pressed is "Applescript" then


openapplication "AppleScript Editor" -- action for 2nd button goes here

else if the button_pressed is "Textedit" then


openapplication "TextEdit" -- action for 3rd button goes here

end if


Best wishes

John M

Syntax error on applescript

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple ID.