title: Cycle through stored names and skip blanks
body: <p>I am trying to make my code more efficient. On scroll button push, the function 'SetName' stores a number to integer <code>iName</code> which is index against 5 names stored in memory.  If a name is not set in memory, it skips to the next.</p>
  
  <p>The code works, but takes up a lot of room. Any advice is appreciated.
  Code:</p>
  
  <pre><code>    #include &lt;string.h&gt;
      int iName = 0;
      int iNewName = 0;
  
      BYTE GetName ()
      {
       return  iName;
      }
  
  
      void SetName (int iNewName)
      {
  
        while (iName != iNewName)
        {
  
        switch (byNewName)
         {
          case 1:
          if (strlen (memory.m_nameA) == 0)
           new_name++;
          else
           iName = iNewName;
          break;
  
          case 2:
          if (strlen (memory.m_nameB) == 0)
           new_name++;
          else
           iName = iNewName;
          break;
  
          case 3:
          if (strlen (memory.m_nameC) == 0)
           new_name++;
          else
           iName = iNewName;
          break;
  
          case 4:
          if (strlen (memory.m_nameD) == 0)
           new_name++;
          else
           iName = iNewName;
          break;
  
          case 5:
          if (strlen (memory.m_nameE) == 0)
           new_name++;
          else
           iName = iNewName;
          break;
  
          default:
          iNewName = 1;
          break;
         } // end of case
  
        } // end of loop
  
      } // end of SetName function
  
  
  void main ()
   {
    while(1)
    {
    if (Button_pushed)
     SetName(GetName+1);
    } // end of infinite loop
  } // end of main
  </code></pre>