title: User input in a matlab GUI
body: <p>Hey all,
  I am building a gui in wich there is an edit box, waiting for the user to write a name.</p>
  
  <p>Currently I force the user to give a legitimate name with this code :</p>
  
  <pre><code>NewPNUName = get(handles.nameOfNewPNU, 'String');
  if ( isempty(NewPNUName) ||...
          strcmp(NewPNUName,'Enter the name for the new PNU') )
      errordlg('Please enter a name for the new PNU.');
  elseif (~ischar(NewPNUName(1)))
      errordlg('The PNU name should start with a letter.');
  else
      handles.NewPNUName = NewPNUName;
  end
  
  if (~isempty(handles.NewPNUName))
  % Do all the things needed if there is a legit name
  end
  </code></pre>
  
  <p>What it does is nothing if the user didn't write a legit name.
  What I want it to do is to make a popup with an edit box, asking the user to input the wanted name again, until it is a legitimate name.</p>
  
  <p>Thanks for the help!</p>
  
  <p>EDIT:
  following @woodchips advice I corrected my code to the foloowing:</p>
  
  <pre><code>NewPNUName = get(handles.nameOfNewPNU, 'String');
  ValidName = ~isempty(NewPNUName) &amp;&amp; isletter(NewPNUName(1)) &amp;&amp;...
      ~strcmp(NewPNUName,'Enter the name for the new PNU');
  while (~ValidName)
  
      if ( isempty(NewPNUName) ||...
              strcmp(NewPNUName,'Enter the name for the new PNU') )
          NewPNUName = char(inputdlg('Please enter a name for the new PNU.','No name entered'));
      elseif (~isletter(NewPNUName(1)))
          NewPNUName = char(inputdlg('The name of the new PNU should start with a letter. Please enter a new name',...
              'Invalid name entered'));
      else
          allConds = 'are met'
      end
  
      ValidName = ~isempty(NewPNUName) &amp;&amp; isletter(NewPNUName(1)) &amp;&amp;...
          ~strcmp(NewPNUName,'Enter the name for the new PNU');
  end
  </code></pre>