HP50g Problem with KEY, SAME



this little program does not work on my HP50g as I expected:


It should wait for a keystroke and then put a 1 on the stack if the PLUS key is pressed or a 0 if any other key is pressed.

Instead it gives 0. for all keystrokes (that is a zero with a decimal point).

The reason seems to be that the KEY command does not return an integer (TYPE 28) but a real Number (TYPE 0) with no decimals. So for the PLUS key it returns 95. but not 95 which is not the SAME.

I found a workaround using R->I, but maybe I overlooked something and there is a simpler solution as this code had worked as expected on my former HP48SX (whose main board is hanging decoratively on the wall of my shack).

So, if somebody here can help me that would be fine.




What about:

/<< DO UNTIL KEY END 95. SAME />>   ?

Works on a 49g...


Edited: 6 Feb 2009, 11:24 a.m.


You seem to have answered your entire question yourself in the first post. Not sure what you are asking really. Like you said, it is a real vs integer thing. Why not just use == ?



Thank you for your suggestions, Massimo and Tim.

What puzzles me is that in the advanced user's reference manual for the hp49g+ Edition 1.1 Printed Date: 2006/3/20 on page 1-46 there is exactly this program:

<< ... DO UNTIL KEY END 95 SAME ... >>

There is no decimal point after the 95 and it always gives the result 0. (zero with decimal point). After changing 95 to 95. it answers the +key with 1.

A discrepancy between the manual and the machine?



Edited: 7 Feb 2009, 2:04 a.m.


SAME and various tests return type 0 result and not type 28 (integer) so what manual says is obviously wrong for the 49/50 series, but right for the 48 where it's been copied from. On the other hand using SAME in this case is not justified. As Tim suggested == should be used.

Interestingly == returns an integer value


Edited: 7 Feb 2009, 5:15 a.m.

Possibly Related Threads...
Thread Author Replies Views Last Post
  hp50g screen weird line Sok-khieng Chum Hun 2 1,108 09-10-2013, 08:11 AM
Last Post: Sok-khieng Chum Hun
  Documentation about Hp50g / 49g+ / 48gII and wikis Pier Aiello 9 2,155 09-10-2013, 04:22 AM
Last Post: Software49g
  "A Penny for your thoughts" on the HP50g Tom Grydeland 3 1,243 08-01-2013, 03:57 AM
Last Post: Les Koller
  Is there a HP50g emulator for Linux? Matti Övermark 2 1,047 07-03-2013, 07:40 AM
Last Post: Matti Övermark
  HP50G advanced applications for mathematics CompSystems 0 795 06-17-2013, 08:38 AM
Last Post: CompSystems
  HP50g rebind stat key Chris Smith 1 841 05-26-2013, 06:21 PM
Last Post: Software49g
  How I use my HP50G at work. David Bengtson 7 1,756 05-06-2013, 02:57 PM
Last Post: Ingo
  HP50g emulator Richard Berler 1 878 03-24-2013, 02:43 PM
Last Post: aurelio
  Focus on the HP50g Mic 13 2,458 01-22-2013, 09:18 PM
Last Post: Ronald Williams
  HP50g and rechargeables Chris Smith 11 2,079 01-07-2013, 02:43 AM
Last Post: Derek Walker (UK)

Forum Jump: