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 &quot;&quot;
repeat while tname is equal to &quot;&quot;
    set tname to text returned of (display dialog ¬
        &quot;Hello&quot; buttons {&quot;next&quot;} ¬
        default button 1 default answer &quot;&quot;)
end repeat
if tname is equal to &quot;&quot; then display dialog &quot;error&quot;
The line
if tname is equal to &quot;&quot; then display dialog &quot;error&quot;

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