I'm trying to write a robust script that will allow the user to specify a Sigma K value and select Y columns from a list of all the continuous columns and create the L-J charts for each and save the limits to a tall data table.
The script isn't creating any errors but isn't creating the graphical output.
I can't see where I'm going wrong, script below and attached
Thanks
Names Default To Here(1);
dt = Current Data Table();
// Get list of continuous columns
contCols = {};
For(i = 1, i <= N Cols(dt), i++,
col = Column(dt, i);
If(col << Get Modeling Type == "Continuous",
Insert Into(contCols, col << Get Name)
);
);
If(N Items(contCols) == 0,
Show Message(
"No continuous columns found.", "Please ensure your data table has continuous columns."
);
Stop();
);
// Dialog for selecting columns and k
colList = .;
kNum = .;
dialogResult = .;
nw = New Window("Levey-Jennings Chart Setup",
<<Modal,
V List Box(
Text Box("Select up to 50 continuous columns:"),
colList = List Box(contCols, maxSelected(50)),
Text Box("Enter k (number of SDs for Shewhart control limits):"),
kNum = Number Edit Box(3)
),
H List Box(
Button Box("OK",
Expr(
dialogResult = 1;
nw << Close Window;
)
),
Button Box("Cancel",
Expr(
dialogResult = 0;
nw << Close Window;
)
)
)
);
If(dialogResult == 1,
selectedCols = colList << Get Selected;
k = kNum << Get;
If(N Items(selectedCols) == 0,
Show Message("No columns selected.", "Please select at least one column.");
Stop();
);
// Build an array of column references for Y()
yColsArray = {};
For(i = 1, i <= N Items(selectedCols), i++,
Insert Into(yColsArray, Column(dt, selectedCols[i]))
);
// Launch Control Chart Builder with expanded array using Eval List()
dt << Control Chart Builder(
Show Two Shewhart Charts(0),
K Sigma(k),
Variables(Y(Eval List(yColsArray))),
Chart(Points(Statistic("Individual")), Limits(Sigma("Levey Jennings"))),
Show Control Panel(0)
);
,
Print("Dialog canceled.")
);
Edit (jthi): added jsl formatting