HP Forums
Possible Unit Comparison bug? - 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: Possible Unit Comparison bug? (/thread-374.html)



Possible Unit Comparison bug? - The Shadow - 01-09-2014 02:12 AM

Hey, I was trying to figure out how to program a key to behave differently with a short press and a long press, and came across something that I suspect is a bug.

Code:
KEY K_7()
BEGIN
LOCAL time;
time:=TIME(KeyTimer(32));
IF time<0.5_s THEN
  RETURN "7";
ELSE
  RETURN "It worked!";  
END;
END;

EXPORT KeyTimer(key)
BEGIN
WHILE ISKEYDOWN(key) DO
END;
END;

Simple as that is, it simply would not work until I did this:

Code:
time:=TIME(KeyTimer(32))/1_s;
IF time<0.5 THEN

This despite the fact that comparatives seem to work just fine on units in the Home screen. Is this a bug, or do I need to do something to prep the unit object in the first bit of code?

Also, not a bug but something worth knowing: I originally tried to use GETKEY in place of the key number of 32, but it didn't work. The KEY function must use GETKEY to return the key number, so when you do it again you get -1.

P.S. I eventually redid the whole thing using TICKS rather than TIME, but I still think the potential bug is worth mentioning.


RE: Possible Unit Comparison bug? - Tim Wessman - 01-09-2014 03:37 PM

Thanks. I'm not sure either, but I've marked it down for examination.