In the code below 'dt' ('dt1') is a reference to the table containing the data (the spec limits). To use the code, do 'File > New > New Script', cut and paste into the window that appears, then do 'Edit > Run Script'.
NamesDefaultToHere(1);
// Make some spec limits to work with
dt1 =
New Table( "Spec Limits",
Add Rows( 3 ),
New Column( "Process",
Character,
"Nominal",
Set Values( {"NPN1", "PNP1", "PNP2"} )
),
New Column( "LSL",
Numeric,
"Continuous",
Set Values( [104.412948990151, 164.389518443879, -136.122122529984] )
),
New Column( "Target",
Numeric,
"Continuous",
Set Values( [118.153221027253, 297.017932186294, 465.441998810449] )
),
New Column( "USL",
Numeric,
"Continuous",
Set Values( [131.893493064355, 429.64634592871, 1067.00612015088] )
)
);
// Make some data to work with
dt =
New Table( "Data",
Add Rows( 10 ),
New Column("NPN1",
Numeric,
"Continuous",
Set Values(
[114.555760105678, 120.043693059459, 114.926510466106, 111.756445551183,
111.545085144313, 113.52359591958, 111.749308571209, 114.411433304976,
118.48975048042, 113.171122695149]
)
),
New Column("PNP1",
Numeric,
"Continuous",
Set Values(
[322.616751775796, 333.128079728678, 348.978757216574, 268.548094462492,
295.073165929223, 323.833298568833, 369.320490694357, 342.987400315929,
315.52243608245, 288.978183718528]
)
),
New Column("PNP2",
Numeric,
"Continuous",
Set Values(
[469.390289765043, 437.781112798903, 532.12814730405, 373.058628529111,
338.900737368942, 469.992171436316, 563.084459366587, 479.378108668814,
530.265608347575, 421.454501563007]
)
)
);
// ******************************************************************************************
// Given a column reference, sets spec liomits property
// ******************************************************************************************
setSpecLimits = function({c, lsl, usl, tar},
cmd = Expr(c << SetProperty("Spec Limits", {LSL(expr(lsl)), USL(expr(usl)), Target(expr(tar))}));
eval(evalexpr(cmd));
);
// ******************************************************************************************
// Given a table dt, and a table dt1 containing spec limits, populates spec limit properties in dt
// ******************************************************************************************
populateSpecs = Function({dt, dt1}, {Default Local},
// Loop over rows of dt1, and iff there is a matching column in dt set its property
clist = dt << GetColumnNames(Numeric, String);
for (r=1, r<=NRows(dt1), r++,
name = Column(dt1, "Process")[r];
lsl = Column(dt1, "LSL")[r];
usl = Column(dt1, "USL")[r];
tar = Column(dt1, "Target")[r];
if (Contains(clist, name), SetSpecLimits(Column(dt, name), lsl, usl, tar));
)
);
// Define the spec limit column properties in dt using dt1
Wait(3);
populateSpecs(dt, dt1);
// Launch the Capability platform (which uses the column properties automatically)
cols = dt << getColumnNames;
dt << Capability(Y(Eval(cols)));