Yes, it looks like the alarm script seems to be a blunt instrument in that there's no obvious way (to me . . . ) that the values of 'qc_sample' can be related to the levels of the 'By' variable, and thence to the appropriate row in the data table.
But, depending on what else is going on in your script, you might be able to use 'Process Screening' to get what you need. The script below should get you started: Run it and inspect the log and the two 'detail' tables it makes.
NamesDefaultToHere(1);
// Make some data
dt = NewTable("Alarms",
NewColumn("By", Numeric, Nominal, Formula(RandomInteger(1,2))),
NewColumn("Data", Numeric, Continuous, Formula(RandomNormal(0,1)))
);
dt << addRows(1000);
// Use process screening invisibly to get the details of all alarms (one table for each level of the 'By' variable)
ps = dt << Process Screening( Y(Column(dt, "Data")), By(Column(dt, "By")), Invisible );
dtList = ps << saveDetailsTable;
Report(ps[1]) << closeWindow;
// Control chart with alarm script
cc = dt << Control Chart(
Chart Col( :Data, Individual Measurement, Moving Range ),
By( :By ),
Alarm Script(
Write(
"Out of Control for test ",
qc_test,
" in column ",
qc_col,
" in sample ",
qc_sample,
"\!N"
)
)
);
// Turn on Test 1
cc << Test 1(1);