HP Forums

Full Version: why doesn't GETKEY work with WAIT (solved)
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I expected this simple program to buffer key input, allowing tapping ESC to exit: it doesn't when WAIT is included, so I have to exit by holding ON to interrupt the program instead.

Is there a better way?,[Android]
Code:


 LOCAL LIGHTH:="HOLD ON/OFF TO EXIT:GETKEY BROKEN";
 EXPORT LIGHTSTEADY()
 BEGIN
  RECT_P(0,0,320,240,0,#FFh);
  TEXTOUT_P(LIGHTH,0,180);
  REPEAT
  //WAIT(−1);
  UNTIL GETKEY==4 ;//UNRELIABLE

 END;

 EXPORT GETKEYPROB()
 BEGIN
  LIGHTSTEADY();
 END;
When you press a key WAIT(-1) returns the key code, you don't need GETKEY after that.
Try to replace:
Code:
  REPEAT
  //WAIT(−1);
  UNTIL GETKEY==4 ;//UNRELIABLE
by:
Code:
  REPEAT UNTIL WAIT(−1)==4 ;
WAIT(-1) itself also captures key presses. So if you press [Esc] during the WAIT(-1) timeout period, the keypress is sent to the WAIT command. GETKEY would then have nothing in the buffer to parse. Save the output from WAIT(-1) and use it to test.
Thanks. I never thought of looking for the key hidden in WAIT.
Reference URL's