I have tried to use a Java book to assist me, but the code here does not seem to be standard Java. I just need the syntax to create a double or single precision floating point array. And then fill it from a existing data table.
"Cartagena? Angel, you are hell and gone from Cartagena."1 App Lab is a version of Javascript. Javascript doesn’t have types. Every array you create is (or I should say can be) a double float array. In fact App Lab only has one type of number that happens to be a double precision float.
If by table you mean the database I always recommend using readRecords()
. It gives you an array of JSON objects where each object is a row from the database. getColumn()
will return an array of values from a single column in the database but it is implemented the same as readRecords()
anyway and isn’t as versatile.
If you need an idea of how that works look at Code.org - App Lab around line 636.
1Thomas, D. (Writer), Douglas, M. (Producer), & Zemeckis, R. (Director). (1984). Romancing the stone [Motion picture]. United States: Twentieth Century-Fox Film Corporation.
Thanks for responding;
My data table only by a very loose definition could be called a database. It is a two column list of numbers. 6-25 lines of Data. I want to read it into a T(i) and F(i) arrays From the time vs force data, I will calculate velocity(i), and a position(i). using the mass, surface area, and drag coefficients. And then plot that data on a chart. I’m not looking to do a lot of database manipulation, Once the data is read into the array I’m done with the table.
Longing for the days of FORTRAN, and Basic
I personally am glad FORTRAN, COBOL, Basic, and PL/1 are gone. I am waiting for the day Java goes extinct. It is long overdue due to Java becoming an instrument of economic oppression.
We talked about you having a CSV file that could be loaded up as a database. I still think that is a good way to go since you could have several versions coexisting in the database and a simple way to choose from them. Perhaps a database for each rocket motor.
If you want to have two arrays then just use getColumn()
. If you want to do something more modern use readRecords()
. The former gives you the syntax T[i]
and F[i]
. The latter leads to forceOverTime[i].time
and forceOverTime[i].force
.
You could also include the data in the code as two 1 dimensional arrays or a two dimensional array. This uses a 2 dimensional array. Code.org - App Lab