HP Forums
Programming Help 48GX - Printable Version

+- HP Forums (https://archived.hpcalc.org/museumforum)
+-- Forum: HP Museum Forums (https://archived.hpcalc.org/museumforum/forum-1.html)
+--- Forum: Old HP Forum Archives (https://archived.hpcalc.org/museumforum/forum-2.html)
+--- Thread: Programming Help 48GX (/thread-67254.html)



Programming Help 48GX - Rick - 01-02-2005

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


Re: Programming Help 48GX - Vieira, Luiz C. (Brazil) - 01-02-2005

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 - V-PN - 01-03-2005

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! - Vieira, Luiz C. (Brazil) - 01-03-2005

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. - Rick - 01-03-2005

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


Re: Thanks guys, I love this site. - Vieira, Luiz C. (Brazil) - 01-03-2005

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. - V-PN - 01-03-2005

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]