0

I expect the code to display an error and then ask the question again when the user enters no text

set tname to ""
repeat while tname is equal to ""
    set tname to text returned of (display dialog ¬
        "Hello" buttons {"next"} ¬
        default button 1 default answer "")
end repeat
if tname is equal to "" then display dialog "error"
2
  • Can you add some details to the question so it doesn't just consist of a block of code without context? What does work, what doesn't? What have you tried to solve the problem already?
    – nohillside
    Commented Jun 24, 2020 at 8:45
  • Please don't just edit the title, edit the question text itself to add details. What doesn't work right now?
    – nohillside
    Commented Jun 24, 2020 at 9:57

1 Answer 1

1

The line

if tname is equal to "" then display dialog "error"

is never reached while tname is empty. You need to put it inside the loop.

0

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .