Post Reply 
why doesn't GETKEY work with WAIT (solved)
10-26-2015, 07:31 AM (This post was last modified: 10-26-2015 12:32 PM by StephenG1CMZ.)
Post: #1
why doesn't GETKEY work with WAIT (solved)
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;

Stephen Lewkowicz (G1CMZ)
https://my.numworks.com/python/steveg1cmz
Visit this user's website Find all posts by this user
Quote this message in a reply
10-26-2015, 08:24 AM
Post: #2
RE: why doesn't GETKEY work with WAIT
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 ;
Find all posts by this user
Quote this message in a reply
10-26-2015, 09:58 AM
Post: #3
RE: why doesn't GETKEY work with WAIT
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.

Graph 3D | QPI | SolveSys
Find all posts by this user
Quote this message in a reply
10-26-2015, 12:36 PM
Post: #4
RE: why doesn't GETKEY work with WAIT (solved)
Thanks. I never thought of looking for the key hidden in WAIT.

Stephen Lewkowicz (G1CMZ)
https://my.numworks.com/python/steveg1cmz
Visit this user's website Find all posts by this user
Quote this message in a reply
Post Reply 




User(s) browsing this thread: 3 Guest(s)