# Translation Help

Hi everyone,

i try to translate a Javascript-Library to Xojo. The following part is the only one, i don’t know, how to do, because Xojo can not handle multiple Arrays. Does anyone of you has an idea?

Greetings

[code]JDE0tab1000 = new Array(
new Array(1721139.29189, 365242.13740, 0.06134, 0.00111, -0.00071),
new Array(1721233.25401, 365241.72562, -0.05323, 0.00907, 0.00025),
new Array(1721325.70455, 365242.49558, -0.11677, -0.00297, 0.00074),
new Array(1721414.39987, 365242.88257, -0.00769, -0.00933, -0.00006)
);

JDE0tab2000 = new Array(
new Array(2451623.80984, 365242.37404, 0.05169, -0.00411, -0.00057),
new Array(2451716.56767, 365241.62603, 0.00325, 0.00888, -0.00030),
new Array(2451810.21715, 365242.01767, -0.11575, 0.00337, 0.00078),
new Array(2451900.05952, 365242.74049, -0.06223, -0.00823, 0.00032)
);

function equinox(year, which)
{
var deltaL, i, j, JDE0, JDE, JDE0tab, S, T, W, Y;

``````if (year < 1000) {
JDE0tab = JDE0tab1000;
Y = year / 1000;
} else {
JDE0tab = JDE0tab2000;
Y = (year - 2000) / 1000;
}

JDE0 =  JDE0tab[which][0] +
(JDE0tab[which][1] * Y) +
(JDE0tab[which][2] * Y * Y) +
(JDE0tab[which][3] * Y * Y * Y) +
(JDE0tab[which][4] * Y * Y * Y * Y);

T = (JDE0 - 2451545.0) / 36525;
W = (35999.373 * T) - 2.47;
deltaL = 1 + (0.0334 * dcos(W)) + (0.0007 * dcos(2 * W));

S = 0;
for (i = j = 0; i < 24; i++) {
S += EquinoxpTerms[j] * dcos(EquinoxpTerms[j + 1] + (EquinoxpTerms[j + 2] * T));
j += 3;
}

JDE = JDE0 + ((S * 0.00001) / deltaL);

return JDE;
``````

}[/code]

Xojo can handle multi-dimensional arrays, you just have to set the values manually. But you can “fake” it instead:

``````dim JDE0tab1000() as double = Array( _
1721139.29189, 365242.13740,  0.06134,  0.00111, -0.00071, _
1721233.25401, 365241.72562, -0.05323,  0.00907,  0.00025, _
1721325.70455, 365242.49558, -0.11677, -0.00297,  0.00074, _
1721414.39987, 365242.88257, -0.00769, -0.00933, -0.00006 )

// 5 items per "array"
// We want to retrieve arr( index1, index2 )

dim value as double = JDE0tab1000( index1 * 5 + index2 )``````

Thank you Kem, i think, i understood your way.

Will the comparison “JDE0tab = JDE0tab1000” work in the right way?

I’m not a Java guy, but that looks like an assignment, not a comparison, right? If so

``````dim JDE0tab() as double
if year < 1000 then
JDE0tab = JDE0tab1000
else
JDE0tab = JDE0tab2000
end if``````

Note that this assigns the array to a second variable, meaning that there will two references to the same array. It does not copy the array.

OK, look to my translation:

[code]Function arr(parent() As Double, index1 As Double, index2 As Double) As Double
Return parent(index1 * 5 + index2)
End Function

Function equinox(year As Integer, which As Double) As Double
Dim deltaL, JDE0, JDE, S, T, W, Y As Double
Dim JDE0tab() As Double
Dim i, j As Integer

If year < 1000 Then
JDE0tab = JDE0tab1000
Y = year / 1000
Else
JDE0tab = JDE0tab2000
Y = (year - 2000) / 1000
End If

JDE0 = arr(JDE0tab, 1, 1) +_
arr(JDE0tab, 2, 2) +_
arr(JDE0tab, 3, 3) +_
arr(JDE0tab, 4, 4) +_
arr(JDE0tab, 5, 5)

T = (JDE0 - 2451545.0) / 36525
W = (35999.373 * T) - 2.47
deltaL = 1 + (0.0334 * dcos(W)) + (0.0007 * dcos(2 * W))

S = 0
j = 0
For i = 0 To 23
S = S + EquinoxpTerms(j) * dcos(EquinoxpTerms(j + 1) + (EquinoxpTerms(j + 2) * T))
j = j + 3
Next

JDE = JDE0 + ((S * 0.00001) / deltaL)

Return JDE
End Function[/code]

But i will get an Error, if i want to get a french Date.

Please look at my Project (original Javascripts and Xojo-Project).
CalCalc.zip