Help with repeating in Applescript
Hi, I'm very new to Applescript(about 2 or 3 days). I've been learning the basic things for Applescript, so I'm trying to make a quiz-like script with 5 questions and answers using a display dialog. When the answer is correct, it goes to the next question. However, if it is wrong, I display a different dialog that says "Wrong!" and I give them two buttons to Press: "Close" or "Restart". I execute error number -128 when the user presses "Close".
But my problem is with the "Restart Button"
The way I want it is when the user presses Restart once they get the answer wrong on any question, I want the whole script to restart and back to the 1st question. I've tried using repeat/end repeat method, but it's not seeming to work. I try to set it to repeat variable Question_1 one time, but it's not working. I need help!
Below is the script for the first Question:
set Question_1 to display dialogQuestionOnedefault answer "" buttons {"OK"} default button 1
if text returned of Question_1 is answer_3 or text returned of Question_1 is answer_4 then
display dialog "Correct!" buttons {"Next"} default button 1
with transaction
end transaction
else
beep
set incorrect to display dialog "Wrong!" buttonsRestartOrClosedefault button 2
if button returned of incorrect is Closing then
error number -128
end if
if button returned of incorrect is Restarting then
repeat 1 times
end repeat
end if
end if
iPhone 4, iOS 5.1.1