Input validation, expect error on null input
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"
Solution 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.