Android Question convert JavaScript Code

gjoisa

Active Member
Licensed User
Longtime User
Tried to convert this JavaScript code to B4A , but could not find a way with my knowledge . Can any one show me the way ?
B4X:
function corr(mlcor, mscor, fcor, dcor, lcor)
{
this.mlcor = mlcor;
this.mscor = mscor;
this.fcor = fcor;
this.dcor = dcor;
this.lcor = lcor;
}

var corrMoon = new Array(); // main
i = 0;
// ml, ms, f, d, l
corrMoon[i++] = new corr( 0, 0, 0, 4, 13.902);
corrMoon[i++] = new corr( 0, 0, 0, 2, 2369.912);
corrMoon[i++] = new corr( 1, 0, 0, 4, 1.979);
corrMoon[i++] = new corr( 1, 0, 0, 2, 191.953);
corrMoon[i++] = new corr( 1, 0, 0, 0, 22639.500);
corrMoon[i++] = new corr( 1, 0, 0, -2, -4586.465);
corrMoon[i++] = new corr( 1, 0, 0, -4, -38.428);
corrMoon[i++] = new corr( 1, 0, 0, -6, -0.393);
corrMoon[i++] = new corr( 0, 1, 0, 4, -0.289);
This code goes on like this .
 

lemonisdead

Well-Known Member
Licensed User
Longtime User
This is simply a list storing the values of a Type line after line.

The Type here is named "corr" and the list is named "corrMoon".

I am on the mobile so I can't share some code but it is easy to do now.
 
Upvote 0

DonManfred

Expert
Licensed User
Longtime User
Can any one show me the way ?
B4X:
Sub Globals
    'These global variables will be redeclared each time the activity is created.
    'These variables can only be accessed from this module.
    Type corr (mlcor As Int, mscor As Int, fcor As Int, dcor As Int, lcor As Double)
End Sub
Sub newCorr(mlcor As Int, mscor As Int, fcor As Int, dcor As Int, lcor As Double) As corr
    Dim mc As corr
    mc.Initialize
    mc.mlcor = mlcor
    mc.mscor = mscor
    mc.fcor = fcor
    mc.dcor = dcor
    mc.lcor = lcor
    Return  mc
End Sub

Sub Activity_Create(FirstTime As Boolean)
    'Do not forget to load the layout file created with the visual designer. For example:
    'Activity.LoadLayout("Layout1")
    Dim corrMoon As List
    corrMoon.Initialize
    corrMoon.Add(newCorr(0, 0, 0, 4, 13.902))
    corrMoon.Add(newCorr(0, 0, 0, 2, 2369.912))
    corrMoon.Add(newCorr(1, 0, 0, 4, 1.979))
    corrMoon.Add(newCorr(1, 0, 0, 2, 191.953))
    corrMoon.Add(newCorr(1, 0, 0, 0, 22639.500))
    corrMoon.Add(newCorr(1, 0, 0, -2, -4586.465))
    corrMoon.Add(newCorr(1, 0, 0, -4, -38.428))
    corrMoon.Add(newCorr(1, 0, 0, -6, -0.393))
    corrMoon.Add(newCorr(0, 1, 0, 4, -0.289))
End Sub
 
Upvote 0
Top