need a spaghetti code translator program or expert

P

Patrick Sullivan

I want to use this algorithm but can't figure it out, I never used BASIC. I
tried translating it but got lost in the gosubs and "for i - 1 to ...
nexts". I have figured out that FNU(X) is degree to radians, and FNY is a
modulo, but those are not what get me confused, it's just this section here.
Anyone in here with "old school BASIC" experience who can unravel this for
fun? :)

1740 DEF FN Y(X) = ATN(SQR(1 - X * X) / X):Y = 0:MO = 360
H(4) = fN U(MC + 180):H(1) = FN U(AS)
1745 R1 = RA + FN R(30):FF = 3: GOSUB 1770:H(5) = FN U(LO + 180
1750 R1 = RA + FN R(60):FF = 1.5: GOSUB 1770:H(6) = FN U(LO + 180
R1 = RA + FN R(120):Y = 1
1755 GOSUB 1770:H(2) = LO:R1 = RA + FN R(150):FF = 3; GOSUB 1770:
H(3) = LO
1760 FOR I = 1 TO 12:H(I) = FN U(H(I)): IF I < 6 THEN H(I) = FN U(H(I-6)
+ 180)
1765 C = H(I): GOSUB 1190:H$(I) = A$: NEXT I: RETURN
1770 X = - 1: IF Y = 1 THEN X = 1
1775 FOR I = 1 TO 10:XX = FN y(X * SIN(R1) * TAN(OB) * TAN(LA)): IF XX < 0
THEN XX = XX * PI
1780 R2 = RA + (XX /FF): IF Y = 1 THEN R2 - RA + PI - (XX / FF)
1785 R1= R2: NEXT 1:LO = ATN(TAN(R1)) / COS(OB)): IF LO < 0 THEN LO = LO +
PI
1790 IF SIN(R1) < 0 THEN LO = LO + PI
1795 LO = FN D(LO): RETURN

TIA
 
M

m.posseth

Well euhhmmm ....... :)


Like GOTO , GOSUB takes a line number to wich the interpreter will jump
however unlike GOTO with GOSUB the jump-from location is stored. At the end
of the subroutine found at the GOSUB jump-to location, you normallly place
a RETURN statement , which causes execution to resume after the GOSUB
statement.

1760 FOR I = 1 TO 12:H(I) = FN U(H(I)): IF I < 6 THEN H(I) = FN U(H(I-6)
+ 180)
1765 C = H(I): GOSUB 1190:H$(I) = A$: NEXT I:

is the same as
FOR I = 1 TO 12
H(I) = FN U(H(I))
IF I < 6 THEN H(I) = FN U(H(I-6) + 180)
C = H(I)
GOSUB 1190 REM :) jump to line number 1190 execute all code untill you
encounter a return statement
H$(I) = A$
NEXT I


did you not see this because of the : ?? wich sperates statements that
should normally be on seperate lines ( i use this still in VB.Net as it is
to today supported )


hth

Michel Posseth [MCP]
 
A

Andrew Morton

Patrick said:
I want to use this algorithm but can't figure it out, I never used
BASIC. I tried translating it but got lost in the gosubs and "for i -
1 to ... nexts". I have figured out that FNU(X) is degree to
radians, and FNY is a modulo, but those are not what get me confused,
it's just this section here. Anyone in here with "old school BASIC"
experience who can unravel this for fun? :)

1740 DEF FN Y(X) = ATN(SQR(1 - X * X) / X)

That's the entire definition of FNY. Just use Math.Acos(X) instead, as
that's what that function does. I'm not sure what the rest of the line is
doing there. Is there a GOSUB 1740 anywhere else in the program?

The rest of the code you show is part of the program. I'm slightly surprised
that there's a DEF FN in what appears to be the middle of it.

For the rest, split it into separate lines at the colons and in-line the
parts that would have been GOSUBs.

So, everywhere you have GOSUB 1770, replace it with

X = - 1
IF Y = 1 THEN X = 1
FOR I = 1 TO 10
XX = Math.Acos(X * SIN(R1) * TAN(OB) * TAN(LA))
IF XX < 0 THEN XX = XX * PI
R2 = RA + (XX /FF)
IF Y = 1 THEN R2 = RA + PI - (XX / FF)
R1= R2
NEXT I
LO = ATN(TAN(R1)) / COS(OB))
IF LO < 0 THEN LO = LO + PI
IF SIN(R1) < 0 THEN LO = LO + PI
LO = FND(LO)

What's the algorithm for? Something better might have been discovered since
it was written.

Andrew
 
P

Patrick Sullivan

That's the entire definition of FNY. Just use Math.Acos(X) instead, as
that's what that function does. I'm not sure what the rest of the line is
doing there. Is there a GOSUB 1740 anywhere else in the program?

Oh, wow, I did not even notice that function doesn't get called. That's the
kind of headache this gave me. I did try translating it, but I eneded up
with "nexts" in functions or subroutines that were not even in the same
block. So I wanted to make the whole thing one sub that doesn't call other
subs, except for the decimal to radians function.
The rest of the code you show is part of the program. I'm slightly surprised
that there's a DEF FN in what appears to be the middle of it.

For the rest, split it into separate lines at the colons and in-line the
parts that would have been GOSUBs.

So, everywhere you have GOSUB 1770, replace it with

Thanks, I don't know how long it would have taken me to figure that out.
X = - 1
IF Y = 1 THEN X = 1
FOR I = 1 TO 10
XX = Math.Acos(X * SIN(R1) * TAN(OB) * TAN(LA))
IF XX < 0 THEN XX = XX * PI
R2 = RA + (XX /FF)
IF Y = 1 THEN R2 = RA + PI - (XX / FF)
R1= R2
NEXT I
LO = ATN(TAN(R1)) / COS(OB))
IF LO < 0 THEN LO = LO + PI
IF SIN(R1) < 0 THEN LO = LO + PI
LO = FND(LO)

What's the algorithm for? Something better might have been discovered since
it was written.

It's one of the only publicly available algorithms for figuring house cusps
in a horoscope in the Placidus method. That method takes 3 great circles
around the celestial zodiac and subdivides them, but then uses some
numerical method that is supposed to be iterated until the cusps don't
change anymore, but this method only uses a few iterations, and disregards
the small resulting error.

Far as I can tell, this same algorith is used in all the public domain
programs that have the source code available (astrolog), and is probably
used in the commercial programs, too. But the astrolog guy translated his
version into C that looks nearly as bad as this BASIC version (lots of
global variables with unknown definitions), so I bought the original BASIC
program listing for $20, and this is the only thing I wanted out of the
entire book. I know a dozen methods for calculatiing planetary positions.
There is also a dll in the Swiss Ephemeris that can calculate ALL the stuff
(sweph), but that's unmanaged code and I don't want to take the time to
learn all the calls for that. Thanks for your help.
Patrick
 
L

Larry Lard

Patrick Sullivan wrote:
[snip]
It's one of the only publicly available algorithms for figuring house cusps
in a horoscope in the Placidus method. That method takes 3 great circles
around the celestial zodiac and subdivides them, but then uses some
numerical method that is supposed to be iterated until the cusps don't
change anymore, but this method only uses a few iterations, and disregards
the small resulting error.

<http://www.widgetsworld.co.uk/search/go.php?art_id=2073> is in PHP but
you don't need to know PHP to parse it. Looks vaguely similar to what
you have, even.

Personally only equal house makes any sense, but each to their own :)
 
P

Patrick Sullivan

Thanks, Larry.

Probably the reason I did not find this is "Placidus domification system." I
never heard it called domification before! php, looks like it uses a lot of
dollar signs. I have that somewhere in my computer, so I can read the
documentation.

--

Patrick Sullivan, AA-BA, BA-IT

Larry Lard said:
Patrick Sullivan wrote:
[snip]
It's one of the only publicly available algorithms for figuring house cusps
in a horoscope in the Placidus method. That method takes 3 great circles
around the celestial zodiac and subdivides them, but then uses some
numerical method that is supposed to be iterated until the cusps don't
change anymore, but this method only uses a few iterations, and disregards
the small resulting error.

<http://www.widgetsworld.co.uk/search/go.php?art_id=2073> is in PHP but
you don't need to know PHP to parse it. Looks vaguely similar to what
you have, even.

Personally only equal house makes any sense, but each to their own :)
 
P

Patrick Sullivan

m.posseth,

I answered you but the message disappeared into hyperspace I suppose, or
else the NSA snagged it. Thanks for the help. I will post what I figured out
in here when I get it working. So far it looks like I have about 6 functions
and subs and about 20 global variables.
--

Patrick Sullivan, AA-BA, BA-IT

m.posseth said:
Well euhhmmm ....... :)


Like GOTO , GOSUB takes a line number to wich the interpreter will jump
however unlike GOTO with GOSUB the jump-from location is stored. At the end
of the subroutine found at the GOSUB jump-to location, you normallly place
a RETURN statement , which causes execution to resume after the GOSUB
statement.

1760 FOR I = 1 TO 12:H(I) = FN U(H(I)): IF I < 6 THEN H(I) = FN U(H(I-6)
+ 180)
1765 C = H(I): GOSUB 1190:H$(I) = A$: NEXT I:

is the same as
FOR I = 1 TO 12
H(I) = FN U(H(I))
IF I < 6 THEN H(I) = FN U(H(I-6) + 180)
C = H(I)
GOSUB 1190 REM :) jump to line number 1190 execute all code untill you
encounter a return statement
H$(I) = A$
NEXT I


did you not see this because of the : ?? wich sperates statements that
should normally be on seperate lines ( i use this still in VB.Net as it is
to today supported )


hth

Michel Posseth [MCP]
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top