Instead of adding a third prompt, I've combined the input in one window. A word of caution (which I should have mentioned before): Spaces are used to separate the values, so any unnecessary spaces (e.g. after the last value) will cause an error.
var w1 = new Window("dialog");
var text1 = w1.add("statictext", undefined, "Enter values (in mm) separated by spaces");
var group1 = w1.add("group");
group1.orientation = "row";
var group2 = group1.add("group");
var text2 = group2.add("statictext", undefined, "Widths (4 values)");
var text3 = group2.add("statictext", undefined, "Heights (3 values)");
var text4 = group2.add("statictext", undefined, "Glue tab width (1 value)");
var group3 = group1.add("group");
group3.orientation = group2.orientation = "column";
group3.alignChildren = group2.alignChildren = ["left","center"];
var input1 = group3.add("edittext", undefined, "100 100 100 100");
var input2 = group3.add("edittext", undefined, "100 100 100");
var input3 = group3.add("edittext", undefined, "30");
input3.preferredSize.width = input2.preferredSize.width = input1.preferredSize.width = 110;
var button1 = w1.add("button", undefined, "OK");
w1.show();
var gap = 8;
var inputWidths = input1.text;
var inputHeights = input2.text;
var f = 2.83465;
var widths = inputWidths.split(" ");
for (var i = 0; i < widths.length; i++) {
widths[i] = Number(widths[i]) * f;
}
var heights = inputHeights.split(" ");
for (var i = 0; i < heights.length; i++) {
heights[i] = Number(heights[i]) * f;
}
if (widths.length == 4 && heights.length == 3) {
var sumWidths = 0;
for (var i in widths) {
sumWidths += widths[i];
}
var sumHeights = 0;
for (var i in heights) {
sumHeights += heights[i];
}
var doc = app.activeDocument;
var ABR = doc.artboards[0].artboardRect;
var paths = doc.pathItems;
var top1 = ABR[3] / 2 + sumHeights / 2;
for (var j = 0; j < heights.length; j++) {
var left1 = ABR[2] / 2 - sumWidths / 2;
for (var i = 0; i < widths.length; i++) {
var top = top1, left = left1, width = widths[i], height = heights[j];
if (j == 0 || j == 2) {
left += (gap / 2) * f;
width -= gap * f;
}
var rect = paths.rectangle(top, left, width, height);
rect.name = "rect" + (j + 1) + "." + (i + 1);
left1 += widths[i];
}
top1 -= heights[j];
}
var glueTab = paths.add();
var topR = paths["rect2.1"].position;
var bottomR = [topR[0], topR[1] - paths["rect2.1"].height];
var topL = [topR[0] - Number(input3.text) * f, topR[1] - 6 * f];
var bottomL = [bottomR[0] - Number(input3.text) * f, bottomR[1] + 6 * f];
glueTab.setEntirePath([topR, bottomR, bottomL, topL, topR]);
for (var i = 1; i < 5; i++) {
paths["rect2." + i].strokeColor = doc.swatches["CMYK Red"].color;
paths["rect2." + i].zOrder(ZOrderMethod.BRINGTOFRONT);
}
} else {
alert("Wrong values were entered. The sketch is 4 boxes wide and 3 boxes high. Enter 4 widths and 3 heights.");
}