Programming Help 48GX



#8

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


#9

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.


#10

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]

#11

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)


#12

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


#13

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.


#14

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]


Possibly Related Threads...
Thread Author Replies Views Last Post
  Programming the 48GX John Rogers 2 221 09-22-2005, 06:30 PM
Last Post: John Rogers
  Custom Programming vs. Pre-packaged programming Eddie Shore 3 331 01-24-2005, 03:42 AM
Last Post: Karl Schneider
  Programming speed on 48GX Naim 10 512 05-20-2004, 04:19 PM
Last Post: Iqbal

Forum Jump: