2

I'm making a text game but can't get it to end the script half way through when the user pushes quit. I have tried quit, return and error -128 but none of them work.

The code isn't inside a tell/end tell because I'm not wanting to use an application, but I've tried putting it inside one with finder and that didn't work either..

Any help is appreciated :)

set temp to display dialog "Welcome" buttons {"Play", "Quit"} if temp = "Quit" then error number -128 end if set temp to display dialog "What is your name?" default answer "Joe" buttons {"Submit"} set userName to text returned of temp etc. etc. 

2 Answers 2

3

Another solution: define the cancel button.

display dialog "Welcome" buttons {"Play", "Quit"} cancel button "Quit" -- no need to check the button returned, the script quit automatically when user cancelled set temp to display dialog "What is your name?" default answer "Joe" buttons {"Submit"} set userName to text returned of temp etc. etc. 
Sign up to request clarification or add additional context in comments.

Comments

1

You should get button returned:

if button returned of temp = "Quit" then error number -128 end if 

2 Comments

Just tried it, it didn't work :( Thanks anyway though
Ah brilliant, I even tried that one and wrote it wrong.. Thanks Nicael :)

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.