The Museum of HP Calculators

HP Forum Archive 07

[ Return to Index | Top of Index ]

HP48 program improvement. . .
Message #1 Posted by Tal on 21 Jan 2002, 3:17 a.m.

Hi, HP48 users!

I have a remote control program that includes a lot of questions in this type of form:

j 6 == i 1 == AND IF THEN 7 'k' STO END j 12 == i 23 == AND IF THEN 8 'k' STO END j 17 == i 45 == AND IF THEN 9 'k' STO END j 56 == i 67 == AND IF THEN 10 'k' STO END j 34 == i 89 == AND IF THEN 11 'k' STO END j 37 == i 111 == AND IF THEN 12 'k' STO END . . . .

I would appreciate it if you could convert these questions so they will operate faster.

Best regards, Tal

      
Re: HP48 program improvement. . .
Message #2 Posted by Vieira, Luiz C. (Brazil) on 21 Jan 2002, 4:54 a.m.,
in response to message #1 by Tal

Hello;

It seems, in a first look, a CASE...THEN... END structure would fit better. If you have problems implementing, send me an e-mail.

Cheers.

      
Re: HP48 program improvement. . .
Message #3 Posted by Joe Panico on 23 Jan 2002, 12:37 p.m.,
in response to message #1 by Tal

Tal,

Assuming the local variables i and j are set elsewhere, the following code works. The original code has no default value or action if an i & j pair is not found, or if neither value is not within the tested values.

{ 7 8 9 10 11 12 } { 6 12 17 56 34 37 } j POS { 1 23 45 67 89 111 } i POS OVER == OVER 0 /= AND IF THEN GET ELSE DROP@ END

This simplifies the code, I'm not sure about the speed. The =/ above is the HP48 not equal test.

Joe


[ Return to Index | Top of Index ]

Go back to the main exhibit hall