The Museum of HP Calculators

HP Forum Archive 19

[ Return to Index | Top of Index ]

HP50g Problem with KEY, SAME
Message #1 Posted by DK2ZA on 6 Feb 2009, 8:58 a.m.

Hello,

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

DO UNTIL KEY END 95 SAME

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.

Regards

Helmut

      
Re: HP50g Problem with KEY, SAME
Message #2 Posted by Massimo Gnerucci (Italy) on 6 Feb 2009, 11:23 a.m.,
in response to message #1 by DK2ZA

What about:

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

Works on a 49g...

Greetings,
Massimo

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

      
Re: HP50g Problem with KEY, SAME
Message #3 Posted by Tim Wessman on 6 Feb 2009, 1:58 p.m.,
in response to message #1 by DK2ZA

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 == ?

TW

            
Re: HP50g Problem with KEY, SAME
Message #4 Posted by DK2ZA on 7 Feb 2009, 2:03 a.m.,
in response to message #3 by Tim Wessman

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?

Regards

Helmut

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

                  
Re: HP50g Problem with KEY, SAME
Message #5 Posted by Reth on 7 Feb 2009, 4:32 a.m.,
in response to message #4 by DK2ZA

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

Cheers, Reth

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


[ Return to Index | Top of Index ]

Go back to the main exhibit hall