HP50g Problem with KEY, SAME



Post: #6

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


Post: #7

What about:

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

Works on a 49g...

Greetings,
Massimo

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

Post: #8

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


Post: #9

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.


Post: #10

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.


Forum Jump: