3 Replies Latest reply on Sep 19, 2016 1:27 PM by gkaiseril

# Help trying to calculate and/or interpret value from table data

Trying to create a form field that would calculate / interpret a value to use for Rng based on given WT and Temp values.

Ex.  At 20 degrees, and a WT of 20, my Rng will be 600.  At a WT of 15, my Rng will be 537.

How can I use an array to help me calculate what my Rng value would be if my WT value falls anywhere in-between two of the listed WT values?

Thanks in advance for any and all help.

• ###### 1. Re: Help trying to calculate and/or interpret value from table data

Yes if you use a multi-dimensional array.

• ###### 2. Re: Help trying to calculate and/or interpret value from table data

Ok great.  Can you point me in the right direction for writing a multi-dimensional array ...?

I'm trying to look through the forum for some examples to better understand and build upon, but got stumped.

• ###### 3. Re: Help trying to calculate and/or interpret value from table data

The Array object from MDN JavaScript Reference.

You first need to create the array, Then assign an array to a value in the first dimension to get the second dimension.

A sample script including loading the table and extracting from the table:

var RngTable = new Array();
RngTable[20] = [null,null,null,null,null,null,null,null,null,null,null,
null,null,null,null,null,null,null,null,null,"600",
null,null,null,null,null,null,null,null,null,"632"];
RngTable[15] = [null,null,null,null,null,null,null,null,null,null,null,
null,null,null,null,null,null,null,null,null,"537",
null,null,null,null,null,null,null,null,null,"600"];
RngTable[10] = [null,null,null,null,null,null,null,null,null,null,null,
null,null,null,null,null,null,null,null,null,"472",
null,null,null,null,null,null,null,null,null,"545"];

var nWT = 10, nTEMP = 30;
console.println("WT: " + nWT + " and TEMP: " + nTEMP + " is " + RngTable[nWT][nTEMP]);