The Museum of HP Calculators

HP Forum Archive 14

[ Return to Index | Top of Index ]

Programming Help 48GX
Message #1 Posted by Rick on 2 Jan 2005, 8:32 p.m.

Given : N45.5645E , How can I drop the number and get NE alone?

      
Re: Programming Help 48GX
Message #2 Posted by Vieira, Luiz C. (Brazil) on 2 Jan 2005, 9:37 p.m.,
in response to message #1 by Rick

Hi, Rick;

the following solution is completely focussed on User RPL, O.K.?

If N45.5645E is a string, you could use the following routine:

2 OVER SIZE 1 - SUB OBJ->
This only works if both left- and right-most characters must be discarded and the number within has a valid syntax.

Hope this helps.

(there are SYSRPL solutions, but I guess others can place them here; I'm just standing in front of the rabit's hole and observing...)

Luiz (Brazil)

Edited: 2 Jan 2005, 9:38 p.m.

            
Re: Programming Help 48GX
Message #3 Posted by Veli-Pekka Nousiainen on 3 Jan 2005, 12:08 a.m.,
in response to message #2 by Vieira, Luiz C. (Brazil)

Q:"Given : N45.5645E , How can I drop the number and get NE alone?"

A: "N45.5645E" is a string at level 1, right?
<< DUP 1 DUP SUB SWAP DUP SIZE DUP SUB + >> 'F&L' STO
You can use the 'F&L' (first and last *) in a program or assign it to a key.

(*) You may substitute Alpha & Omega at will.
[VPN]

            
Oops! My answer does the opposite... Sorry!
Message #4 Posted by Vieira, Luiz C. (Brazil) on 3 Jan 2005, 12:22 a.m.,
in response to message #2 by Vieira, Luiz C. (Brazil)

Hi, Rick;

After reading VPN's (correct) answer I realized that I dropped what you wanted to be kept and kept what you wanted to drop... My mistake!

Sorry...

Luiz (Brazil)

                  
Thanks guys, I love this site.
Message #5 Posted by Rick on 3 Jan 2005, 5:39 a.m.,
in response to message #4 by Vieira, Luiz C. (Brazil)

Glad for both solutions Luiz. I also needed the value. Thanks again.

                        
Re: Thanks guys, I love this site.
Message #6 Posted by Vieira, Luiz C. (Brazil) on 3 Jan 2005, 8:12 a.m.,
in response to message #5 by Rick

HI, Rick;

if you want to put both in the same "package", maybe using local variables is easier. You can try this: (VPN, I'm using part of your 'engine', O.K.?)

« DUP SIZE OVER -> S T
  « T 2 S 1 - SUB OBJ->
    T 1 1 SUB T S S SUB +
  »
»

L1 L3 L2 L1 "Z123.456W" -> "Z123.456W" 123.456 "ZW"

The program holds a copy of the original string and returns both the number and the two ASCII characters bordering it. If you don't need a copy of the original argument, you can try this one:
« DUP SIZE -> T S
  « T 2 S 1 - SUB OBJ->
    T 1 1 SUB T S S SUB +
  »
»

L1 L2 L1 "Z123.456W" -> 123.456 "ZW"

Hope this is closer to what you actualy want.

Cheers.

Luiz (Brazil)

Edited: 3 Jan 2005, 10:26 a.m.

                              
Re: Thanks guys, I love this site.
Message #7 Posted by Veli-Pekka Nousiainen on 3 Jan 2005, 11:38 a.m.,
in response to message #6 by Vieira, Luiz C. (Brazil)

One possible solution:
/<< DUP 2 OVER SIZE SUB STR/->
/->STR 2 2 SUB ROT 1 1 SUB SWAP +
/>> 'F&L' STO
"Z123.456W"
F&L =>
123.456
"ZW"
[VPN]


[ Return to Index | Top of Index ]

Go back to the main exhibit hall