HP Forums
why doesn't GETKEY work with WAIT (solved) - Printable Version

+- HP Forums (https://www.hpmuseum.org/forum)
+-- Forum: HP Calculators (and very old HP Computers) (/forum-3.html)
+--- Forum: HP Prime (/forum-5.html)
+--- Thread: why doesn't GETKEY work with WAIT (solved) (/thread-5011.html)



why doesn't GETKEY work with WAIT (solved) - StephenG1CMZ - 10-26-2015 07:31 AM

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;



RE: why doesn't GETKEY work with WAIT - Didier Lachieze - 10-26-2015 08:24 AM

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 ;



RE: why doesn't GETKEY work with WAIT - Han - 10-26-2015 09:58 AM

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.


RE: why doesn't GETKEY work with WAIT (solved) - StephenG1CMZ - 10-26-2015 12:36 PM

Thanks. I never thought of looking for the key hidden in WAIT.