Not particularly elegant, but you can coerce the 'Alarm Script()' to do this using the approach below (for details of the 'Alarm Script()' see the 'Scripting Guide' under 'Help > Books'):
NamesDefaultToHere(1);
ClearLog(); // Required beacuse we need to 'scrape' the contents of the log window (see below)
// Make a sample data table. Because the data generated is perfectly 'in control' we may need lots of samples
ss = 5; // Sample Size
ns = 500; // Number of Samples
sv = SortAscending(Repeat((1::ns)`, ss));
dt = NewTable("Using an Alarm Script Retrospectively",
NewColumn("Weight", Numeric, Continuous, Formula(RandomNormal(0, 1))),
NewColumn("Sample", Numeric, Continuour, Values(sv))
);
// Make an XBar - R chart, and apply three of the tests to flag out of control conditions
dt << Control Chart(
// Note that the alarm script HAS TO APPEAR FIRST inside 'ControlChart()'!
Alarm Script( Write("--->Failing Rule Number: ", QC_Test, " Sample Number: ", QC_Sample, " Sample start row: ", QC_FirstRow, " Sample end row: ", QC_LastRow, "\!N") ),
Chart Col( :Weight, Xbar( Test 1( 1 ), Test 2( 1 ), Test 5( 1 ) ), R ),
Sample Size( :Sample ),
Ksigma( 3 )
);
// The alarm script only gives options to 'Speak', 'Write' (to the log and used above) or 'Email', because as the name implies, it is intended for real time
// use. To use it retrospectively, the best way is to 'scrape' the necessary values from the log window . . .
txt = GetLog(); // txt is a list, with (text) items corresponding to each row in the log window
// This code selects all rows in dt that are associated with an out of control flag . . .
rows2select = [];
for (a=1, a<=NItems(txt)-1, a++,
wordsInLine = Words(txt[a], " ");
if(wordsInLine[1] == "--->Failing",
sampleStartRow = Num(wordsInLine[11]);
sampleEndRow = Num(wordsInLine[15]);
rows2select = VConcat(rows2select, (sampleStartRow::sampleEndRow)`)
);
);
dt << selectRows(rows2select);