Skip to main content
Participating Frequently
September 19, 2016
Answered

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

  • September 19, 2016
  • 1 reply
  • 757 views

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.

This topic has been closed for replies.
Correct answer gkaiseril

Yes if you use a multi-dimensional array.

1 reply

gkaiserilCorrect answer
Inspiring
September 19, 2016

Yes if you use a multi-dimensional array.

Participating Frequently
September 19, 2016

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.

Inspiring
September 19, 2016

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]);