Post Reply 
Bug i GETKEY (8151)
06-27-2015, 08:31 AM
Post: #1
Bug i GETKEY (8151)
The following program should complete when you press any key. However, when during the operation touches 3 times the display a program can be terminated only by pressing the On.

EXPORT TESTGETKEY()
BEGIN
LOCAL i,a;
AAngle▶a;
2▶AAngle;
REPEAT
RECT_P();
ARC_P(G0,160,120,100);
LINE_P(160,120,100*COS(i)+160,100*SIN(i)+120);
i+5▶i;
WAIT(.5)
UNTIL GETKEY≥0;
a▶AAngle
END;


Attached File(s)
.zip  TESTGETKEY.zip (Size: 383 bytes / Downloads: 1)
Find all posts by this user
Quote this message in a reply
06-27-2015, 09:50 AM
Post: #2
RE: Bug i GETKEY (8151)
The "WAIT(.5)" command on line 11 is missing the ending semicolon, (posted program). Adding the semi, the program seems to terminate on any keypress, which is what, I think, you intended.

Code:

EXPORT TESTGETKEY()
BEGIN

  LOCAL i,a;
  AAngle▶a;
  2▶AAngle;

  REPEAT
    RECT_P();
    ARC_P(G0,160,120,100);
    LINE_P(160,120,100*COS(i)+160,100*SIN(i)+120);
    i+5▶i;
    WAIT(.5);           //  <==  added semicolon here
  UNTIL GETKEY≥0;

  a▶AAngle

END;
Find all posts by this user
Quote this message in a reply
06-27-2015, 10:00 AM
Post: #3
RE: Bug i GETKEY (8151)
semicolon in line 11 is not needed
Find all posts by this user
Quote this message in a reply
06-27-2015, 10:14 AM (This post was last modified: 06-27-2015 10:15 AM by DrD.)
Post: #4
RE: Bug i GETKEY (8151)
Well, then neither is the WAIT(.5) command, since it won't complete that command without it. Here is the revised program ... kinda cute!:

Code:

EXPORT TESTGETKEY()
BEGIN
LOCAL i,a;
AAngle▶a;
2▶AAngle;
REPEAT
RECT_P();
ARC_P(G0,160,120,100);
LINE_P(160,120,100*COS(i)+160,100*SIN(i)+120);
i+5▶i;

UNTIL GETKEY≥0;
a▶AAngle
END;
Find all posts by this user
Quote this message in a reply
06-27-2015, 10:29 AM
Post: #5
RE: Bug i GETKEY (8151)
Please try 3 times to touch the screen while the program working and then a key
Find all posts by this user
Quote this message in a reply
06-27-2015, 10:59 AM
Post: #6
RE: Bug i GETKEY (8151)
(06-27-2015 10:00 AM)slawek39 Wrote:  semicolon in line 11 is not needed
Why?
The manual states on page 492:
"Commands are separated by a semicolon ( ; ). "
Find all posts by this user
Quote this message in a reply
06-27-2015, 11:05 AM
Post: #7
RE: Bug i GETKEY (8151)
(06-27-2015 10:29 AM)slawek39 Wrote:  Please try 3 times to touch the screen while the program working and then a key

OK, just to be clear: I was using the VC, not the HC. I didn't actually "touch" the screen ... only noticed the missing semi, and verified that the program would not exit on random key press without it, and that it does exit on random key press with the semi in place...

My HC is not available right now, so perhaps you are right, and someone else may be able to help mitigate the issue.

-Dale-
Find all posts by this user
Quote this message in a reply
06-27-2015, 11:05 AM
Post: #8
RE: Bug i GETKEY (8151)
WAIT (.5) is the last command in the block REPEAT ... UNTIL so the semicolon is not needed
Find all posts by this user
Quote this message in a reply
10-12-2015, 11:05 PM
Post: #9
RE: Bug i GETKEY (8151)
Tapping the screen three times on the Android, needs an ON with this code.

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-13-2015, 12:28 PM
Post: #10
RE: Bug i GETKEY (8151)
It was discussed here:
http://www.hpmuseum.org/forum/thread-4888.html

Piotr Kowalewski
Find all posts by this user
Quote this message in a reply
10-14-2015, 05:41 AM
Post: #11
RE: Bug i GETKEY (8151)
Hello,

The root cause is the limited event stack of the Prime.
Any event goes in the queue, Key presses, but also mouse messages.
If you type on the screen 3 times, you have at least 9 messages in the queue: 3 times Down, Up and Click.
Since nothing is consuming these messages, they stay there.
Since the queue is 8 deep, any other messages are ignored (so, in fact the last click is not there).
As a result, your key press never makes it into the queue and never triggers GetKey.

The WAIT(-1) command does allow to get stuff from, and out of, the queue, but that is the only way at this point in time.

Cyrille

Although I work for the HP calculator group, the views and opinions I post here are my own. I do not speak for HP.
Find all posts by this user
Quote this message in a reply
10-14-2015, 09:44 PM (This post was last modified: 10-14-2015 09:45 PM by hpfx.)
Post: #12
RE: Bug i GETKEY (8151)
(10-14-2015 05:41 AM)cyrille de brébisson Wrote:  The root cause is the limited event stack of the Prime.
Hi,
And why not two event queues ?
one for keyboard, and another one for mouse events.

WAIT(0) will consume key-queue events
WAIT(-1) from key or mouse queue
MOUSE() from mouse-queue

that's the only way to avoid the queue to be fullfilled by event type not consumed that void pushing other event types.
Increasing a unique queue is a workaround but not a good solution.
Find all posts by this user
Quote this message in a reply
10-17-2015, 07:59 AM (This post was last modified: 10-17-2015 01:21 PM by StephenG1CMZ.)
Post: #13
RE: Bug i GETKEY (8151)
(10-14-2015 05:41 AM)cyrille de brébisson Wrote:  Hello,

The root cause is the limited event stack of the Prime.
Any event goes in the queue, Key presses, but also mouse messages.
If you type on the screen 3 times, you have at least 9 messages in the queue: 3 times Down, Up and Click.
Since nothing is consuming these messages, they stay there.
Since the queue is 8 deep, any other messages are ignored (so, in fact the last click is not there).
As a result, your key press never makes it into the queue and never triggers GetKey.

The WAIT(-1) command does allow to get stuff from, and out of, the queue, but that is the only way at this point in time.

Cyrille

This little program demonstrates a way of dealing with the mouse events.
It might not be a perfect solution, but it certainly seems to improve the robustness of the code. Try tapping the screen 3 times with and without the mouse statement to see the difference.
But if you need to keep checking the mouse, it would be better if the system could do that for you.

Code:

 LOCAL ZIPPST:="ZIPP V 0.0 ";
 LOCAL SG:=" StephenG1CMZ";
 LOCAL CRID:=ZIPPST+"© 2015 "+SG;

 MSNK()
 BEGIN
   LOCAL SNK:=MOUSE();
 END;

 EXPORT MEASURE_INTERVAL_S()
 BEGIN
  LOCAL TICKB,TICKE,TICKL;
  LOCAL TS;
  LOCAL MI:=0;
  LOCAL MST:="MEASURE SHORT INTERVAL
tap OK or Enter to start
TAP ANY KEY TO END";

  
  TICKB:=MSGBOX(MST,1);
  IF TICKB THEN
   RECT();
   TICKB:=Ticks; TS:=Time;
   TICKL:=TICKB;
   REPEAT 
    MSNK;
    IF Ticks-TICKL≥1000 THEN
     TICKL:=Ticks;
     RECT();
     TEXTOUT_P(→HMS(ROUND((Ticks-TICKB)/1000,0)/3600),0,20);
     MSNK;
    END;
    WAIT(0.001);
    MSNK;
   UNTIL GETKEY≥0;
   TICKE:=Ticks;
   MI:=(TICKE-TICKB)/1000;
  END;
  RETURN ROUND(MI,0);  
 END;

 EXPORT G1CMZ_IMMENSELY_PRACTICAL_PACKAGE ()
 BEGIN

 END;

 EXPORT ZIPP()
 BEGIN

 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
Post Reply 




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