Moving in and out of a do while loop?

If I separated the decoding and the if/else how would I know what pattern to do? Either I'd have a decoded IR signal with nothing to test it against or I'd have an if/else chain that wouldn't ever get activated.

I don't understand why.

unsigned long whatToDo = 0;

void loop()
{
   if(irrecv.decode(&results))
   {
      whatToDo = results.value;
   }

   switch(whatToDo)
   {
      case 0:
         // Don't do anything
         break;
      case up:
         Serial.write(" up ");
         dspeed = dspeed + 100;
         whatToDo = 0;
         break;
      // Other cases
   }
}

Here, deciding whether there is a change in what to do, and doing what needs to (still) be done are separate.

You could press the right button and

      Serial.write("right");
      whitemedium();

would be executed over and over until you pressed another button.