Hi,
currently I am writing a program to convert one astronomical coordinate system into another one. The algorithms are written in a book I bought used, which is called "Practical Astronomy with your calculator".
In a certain step, the description says something like:
Depending on x and y being either positive or negative you have to add or to subtract
360 degree or 180 degree from h.
So there are four cases to destinquish:
+x +y
+x y
x y
x +y
Trying to avoid GTO (which is the most evil of all commands of all time...we know (...) I was trying
to find a small and neat solution which avoids unnecessary code executions.
The only way I found is the opposite of that:
RCL "x"
x>0
XEQ 00 ; the subroutine "pollutes" the stack...
RCL "x"
x<0
XEQ 01 ; stack pollution again
GTO 99 ; end...
LBL 00
RCL Y
X>0
XEQ 02 ; stack pollution again
RCL Y
X<0
XEQ 03 ; stack pollution again
RTN
LBL 01
RCL Y
X>0
XEQ 04 ; stack pollution again
RCL Y
X<0
XEQ 05 ; stack pollution again
RTN
LBL 02
; do the math here
RTN
LBL 03
; do the math here
RTN
LBL 04
; do the math here
RTN
LBL 05
; do the math here
RTN
LBL 99
.END.
Is there any, more elegant way to do a
IF (( cond 1) && (cond 2)) {
} else
IF .....
type of thing?
Thanks a lot for any help for a bloody RPN/FOCAL beginner (since 31.12.2017)!
Cheers
Meino
DM42: Programming question: Best practice for...
DM42: Programming question: Best practice for...
DM 42  SN: 00373, Firmware v.:3.5

 Posts: 472
 Joined: Mon Apr 24, 2017 6:38 pm
Re: DM42: Programming question: Best practice for...
I'd probably put a conditional check that puts either 1 or 2 on the stack, then another that puts either 1 or 1 on the stack (some rolling involved), then product of them and 180 aught to do it. Without the formula and conditions though it's hard to guess what you're trying to do
Re: DM42: Programming question: Best practice for...
Hi Keith,
oh yeah! That's a neat idea...will implemented it that way! Great!
THANK YOU!
Cheers
Meino
oh yeah! That's a neat idea...will implemented it that way! Great!
THANK YOU!
Cheers
Meino
DM 42  SN: 00373, Firmware v.:3.5