Shop OBEX P1 Docs P2 Docs Learn Events
Use of do ... while — Parallax Forums

Use of do ... while

RsadeikaRsadeika Posts: 3,837
edited 2013-09-21 16:23 in Propeller 1
The result that I am trying to get is, when I press the 'q' key, the program breaks out of the loop. Right now, it runs through once and then it does not do anything except respond to the 'q' press. I expect the program to keep posting a distance value while the 'q' has not been pressed. Anybody care to set me straight?

Thanks

Ray
void testping(void)
{
  int distance;
  print("Press 'q' to quit\n");  
//  while(getChar() != 'q')
//  while(1)
  do
  {
    distance = ping_cm(8);
    print("%c%d distance = %d%c cm",
      CRSRY,1, distance, CLREOL);
    pause(200);
  } while(getChar() != 'q');
}

Comments

Sign In or Register to comment.