JSL for specifying variable number of Phase Levels in a Control ChartHello. I'm writting a script to automate the creation of control charts based on some configuration I'm reading in for each chart to be created. Below is a code snipet for creating a control chart. This chart contains two different phases where the Phase Level command is used to specify the Sigma and Avg within the phases.
chart = Control Chart(
Sample Label ( Column(dt, chartConfig["XParamName"]) ),
Phase( Column(dt, chartConfig["PhaseColumn"]) ),
Group Size( 1 ),
Chart Col(
column(dt,chartConfig["YParamName"]),
Individual Measurement(
Phase Level( "1", Sigma(p1_CL_Range/3), Avg(p1_Mean_calc)),
Phase Level( "2", Sigma(p2_CL_Range/3), Avg(p2_Mean_calc))
)
)
);I'd like to be able to do this for any number of phases, where I would have the phases specified in my configuration info and loop through them. But I don't know how to make a call to Phase Level () like that. I figure there are maybe three options :
- create the control chart object without the Phase Level info and then issue a message (or Send to Report - Dispatch) to the control chart object that will add the Phase Levels in a for loop and then call chart << Redo Analysis(),
- have a function with a loop embedded within the Control Chart( Chart Col(Individiaul Measurement ())) commands, but I don't know how to do that or if it is possible, or
- have the for loop before the Control Chart() command, and save the Phase Level() commands to a list variable and then use that list somehow within the Control Chart () command.
Re: JSL for specifying variable number of Phase Levels in a Control ChartThanks for that suggestion, @txnelson. That gets the job done for me.
Re: JSL for specifying variable number of Phase Levels in a Control ChartMany times, the way that I handle such things, is to use JSL to create all of the code that needs to be used, into one long string variable, and then once done, execute that code.
The sample below is an untested example of such
Phases = 3;
theExpr =
"chart = Control Chart(
Sample Label( Column( dt, chartConfig[\!"XParamName\!"] ) ),
Phase( Column( dt, chartConfig[\!"PhaseColumn\!"] ) ),
Group Size( 1 ),
Chart Col(
Column( dt, chartConfig[\!"YParamName\!"] ),
Individual Measurement(";
For( i = 1, i <= Phases, i++,
theExpr = theExpr || "Phase Level( \!"" || Char( i ) || "\!",
Sigma( p" || Char( i ) || "_CL_Range / 3 ), Avg( p" || Char( i ) ||
"_Mean_calc ) ),"
);
theExpr = theExpr || ")));";
Eval( Parse( theExpr ) );