Keep getting SyntaxError: missing ) in parenthetical 46:
I've renamed my Array and keep getting this error. When I run script with the renamed Array in the console, it calculates appropriately. I've tried going through line by line and can't seem to find the error. Might be I just need a fresh set of eyes to catch my mistake. As per usual, everyones help & advice is greatly appreciated.
(original script)
var AW = this.getField("Weight").value;
var t = this.getField("Temperature").value;
var b = Math.ceil(AW / 1000) * 1000;
var c = Math.floor(AW / 1000) * 1000;
var d = 10000;
var e = 18300;
var m = 1;
var UpperWt = b;
if (b > e) {
UpperWt = e;
}
var LowerWt = c;
if (c < d) {
LowerWt = d;
}
var RngTable = new Array();
RngTable[18300] = ["4686","4857","5029","5201","5942","7370"];
RngTable[18000] = ["4530","4695","4860","5025","5732","7088"];
RngTable[17000] = ["4010","4152","4295","4437","5031","6149"];
RngTable[16000] = ["3550","3675","3800","3925","4412","5285"];
RngTable[15000] = ["3127","3229","3330","3431","3857","4663"];
RngTable[14000] = ["2744","2841","2938","3035","3412","4090"];
RngTable[13000] = ["2382","2461","2540","2619","2925","3475"];
RngTable[12000] = ["2242","2314","2385","2456","2727","3203"];
RngTable[11000] = ["2160","2227","2295","2362","2592","2958"];
RngTable[10000] = ["2085","2152","2220","2287","2493","2787"];
var nWT = this.getField("Weight").value;
var nTEMP = 5;
var f = Math.round(RngTable[UpperWt][nTEMP]);
var g = Math.round(RngTable[LowerWt][nTEMP]);
if (t >= (-18) && t < (-7)) {
var f = Math.round(((((RngTable[UpperWt][nTEMP-4]) - (RngTable[UpperWt][nTEMP-5])) / 11) * (t + 18)) + (1 * RngTable[UpperWt][nTEMP-5]));
var g = Math.round(((((RngTable[LowerWt][nTEMP-4]) - (RngTable[LowerWt][nTEMP-5])) / 11) * (t + 18)) + (1 * RngTable[LowerWt][nTEMP-5]));
} else if (t >= (-7) && t < 0) {
var f = Math.round(((((RngTable[UpperWt][nTEMP-3]) - (RngTable[UpperWt][nTEMP-4])) / 11) * (t + 7)) + (1 * RngTable[UpperWt][nTEMP-4]));
var g = Math.round(((((RngTable[LowerWt][nTEMP-3]) - (RngTable[LowerWt][nTEMP-4])) / 11) * (t + 7)) + (1 * RngTable[LowerWt][nTEMP-4]));
} else if (t >= 0 && t < 4) {
var f = Math.round(((((RngTable[UpperWt][nTEMP-3]) - (RngTable[UpperWt][nTEMP-4])) / 11) * (t - 4)) + (1 * RngTable[UpperWt][nTEMP-3]));
var g = Math.round(((((RngTable[LowerWt][nTEMP-3]) - (RngTable[LowerWt][nTEMP-4])) / 11) * (t - 4)) + (1 * RngTable[LowerWt][nTEMP-3]));
} else if (t >= 4 && t < 16) {
var f = Math.round(((((RngTable[UpperWt][nTEMP-2]) - (RngTable[UpperWt][nTEMP-3])) / 11) * (t - 4)) + (1 * RngTable[UpperWt][nTEMP-3]));
var g = Math.round(((((RngTable[LowerWt][nTEMP-2]) - (RngTable[LowerWt][nTEMP-3])) / 11) * (t - 4)) + (1 * RngTable[LowerWt][nTEMP-3]));
} else if (t >= 16 && t < 27) {
var f = Math.round(((((RngTable[UpperWt][nTEMP-1]) - (RngTable[UpperWt][nTEMP-1])) / 11) * (t - 16)) + (1 * RngTable[UpperWt][nTEMP-2]));
var g = Math.round(((((RngTable[LowerWt][nTEMP-1]) - (RngTable[LowerWt][nTEMP-1])) / 11) * (t - 16)) + (1 * RngTable[LowerWt][nTEMP-2]));
} else if (t >= 27 && t < 38) {
var f = Math.round(((((RngTable[UpperWt][nTEMP]) - (RngTable[UpperWt][nTEMP-1])) / 11) * (t - 27)) + (1 * RngTable[UpperWt][nTEMP-1]));
var g = Math.round(((((RngTable[LowerWt][nTEMP]) - (RngTable[LowerWt][nTEMP-1])) / 11) * (t - 27)) + (1 * RngTable[LowerWt][nTEMP-1]));
}
var h = (UpperWt-LowerWt);
if (h == 0) {
h = m;
}
if (AW >= LowerWt && AW <= UpperWt) {
this.getField("CWt_Dist").value = ((((f - g) / (h)) * (AW - LowerWt)) + (g));
}
If AW = 17500 & t = 16, this calculates correctly to 4731
(Script with renamed array)
var AW = this.getField("Weight").value;
var t = this.getField("Temperature").value;
var b = Math.ceil(AW / 1000) * 1000;
var c = Math.floor(AW / 1000) * 1000;
var d = 10000;
var e = 18300;
var m = 1;
var UpperWt = b;
if (b > e) {
UpperWt = e;
}
var LowerWt = c;
if (c < d) {
LowerWt = d;
}
var DistTable = new Array();
DistTable[18300] = ["4686","4857","5029","5201","5942","7370"];
DistTable[18000] = ["4530","4695","4860","5025","5732","7088"];
DistTable[17000] = ["4010","4152","4295","4437","5031","6149"];
DistTable[16000] = ["3550","3675","3800","3925","4412","5285"];
DistTable[15000] = ["3127","3229","3330","3431","3857","4663"];
DistTable[14000] = ["2744","2841","2938","3035","3412","4090"];
DistTable[13000] = ["2382","2461","2540","2619","2925","3475"];
DistTable[12000] = ["2242","2314","2385","2456","2727","3203"];
DistTable[11000] = ["2160","2227","2295","2362","2592","2958"];
DistTable[10000] = ["2085","2152","2220","2287","2493","2787"];
var nWT = this.getField("Weight").value;
var nTEMP = 5;
var f = Math.round(DistTable[UpperWt][nTEMP]);
var g = Math.round(DistTable[LowerWt][nTEMP]);
if (t >= (-18) && t < (-7)) {
var f = Math.round(((((DistTable[UpperWt][nTEMP-4]) - (DistTable[UpperWt][nTEMP-5])) / 11) * (t + 18)) + (1 * DistTable[UpperWt][nTEMP-5]));
var g = Math.round(((((DistTable[LowerWt][nTEMP-4]) - (DistTable[LowerWt][nTEMP-5])) / 11) * (t + 18)) + (1 * DistTable[LowerWt][nTEMP-5]));
} else if (t >= (-7) && t < 0) {
var f = Math.round(((((DistTable[UpperWt][nTEMP-3]) - (DistTable[UpperWt][nTEMP-4])) / 11) * (t + 7)) + (1 * DistTable[UpperWt][nTEMP-4]));
var g = Math.round(((((DistTable[LowerWt][nTEMP-3]) - (DistTable[LowerWt][nTEMP-4])) / 11) * (t + 7)) + (1 * DistTable[LowerWt][nTEMP-4]));
} else if (t >= 0 && t < 4) {
var f = Math.round(((((DistTable[UpperWt][nTEMP-3]) - (DistTable[UpperWt][nTEMP-4])) / 11) * (t - 4)) + (1 * DistTable[UpperWt][nTEMP-3]));
var g = Math.round(((((DistTable[LowerWt][nTEMP-3]) - (DistTable[LowerWt][nTEMP-4])) / 11) * (t - 4)) + (1 * DistTable[LowerWt][nTEMP-3]));
} else if (t >= 4 && t < 16) {
var f = Math.round(((((DistTable[UpperWt][nTEMP-2]) - (DistTable[UpperWt][nTEMP-3])) / 11) * (t - 4)) + (1 * DistTable[UpperWt][nTEMP-3]));
var g = Math.round(((((DistTable[LowerWt][nTEMP-2]) - (DistTable[LowerWt][nTEMP-3])) / 11) * (t - 4)) + (1 * DistTable[LowerWt][nTEMP-3]));
} else if (t >= 16 && t < 27) {
var f = Math.round(((((DistTable[UpperWt][nTEMP-1]) - (DistTable[UpperWt][nTEMP-1])) / 11) * (t - 16)) + (1 * DistTable[UpperWt][nTEMP-2]));
var g = Math.round(((((DistTable[LowerWt][nTEMP-1]) - (DistTable[LowerWt][nTEMP-1])) / 11) * (t - 16)) + (1 * DistTable[LowerWt][nTEMP-2]));
} else if (t >= 27 && t < 38) {
var f = Math.round(((((DistTable[UpperWt][nTEMP]) - (DistTable[UpperWt][nTEMP-1])) / 11) * (t - 27)) + (1 * DistTable[UpperWt][nTEMP-1]));
var g = Math.round(((((DistTable[LowerWt][nTEMP]) - (DistTable[LowerWt][nTEMP-1])) / 11) * (t - 27)) + (1 * DistTable[LowerWt][nTEMP-1]));
}
var h = (UpperWt-LowerWt);
if (h == 0) {
h = m;
}
if (AW >= LowerWt && AW <= UpperWt) {
this.getField("CWt_Dist").value = ((((f - g) / (h)) * (AW - LowerWt)) + (g));
}
SyntaxError: missing ) in parenthetical
46: at line 47
