You have changed some of the statements that should not have been changed. I have commented out the inappropriate lines, and changed them back. I have also added in functionality that runs a control chart and strips off the Control Limits and uses them as the values to transform back into the original distribution.
Names Default To Here( 1 );
dt=current data table();
theColumn = dt<<get selected columns("string");
if(n items(theColumn)!=1,
throw("Incorrect number of columns selected, must be just one");
);
nw=new window("calculate control limits limits",
Panel Box("actions",
Hlistbox(
bb1=Buttonbox("press to get Limits",
nebvalue1=neb1<<get;
nebvalue2=neb2<<get;
obj=Distribution(
Continuous Distribution(
Column( as column(theColumn) ),
Process Capability( Use Column Property Specs ),
Fit Johnson(save distribution formula)
),
invisible(1),
SendToReport(
Dispatch( {eval(theColumn)}, "Process Capability", OutlineBox, {Close( 1 )} )
)
);
obj<<close window;
// Run the Control Chart and strip off the LCL and UCL
ccb = /* Control Chart Builder(
Variables( Y( column(ncols(dt)) ) ),
Show Control Panel( 0 )
);*/
Control Chart Builder(
Variables( Y( column(ncols(dt)) ) ) ,
Set Subgroup Size( 5 ),
Show Control Panel( 0 )
);
// Get the Target LCL and Target UCL from the Displayed Report
theTarget_lcl = (report(ccb)[NumberColBox("LCL")]<<get)[1];
theTarget_ucl = (report(ccb)[NumberColBox("UCL")]<<get)[1];
ccb << close window;
// Find the back transform of the calculated mean of the transformed distribution
theTargetCol = Column( dt, N Cols( dt ) ) << get name;
theFormula_lcl = Char( As Column( dt, theTargetCol ) << get formula );
//theTarget_lcl = nebvalue1;
// Change the reference to the original column used in the transformation to _X_
// so it can be used in the back transform
Substitute Into( theFormula_lcl, ":"|| theColumn[1], "_X_" );
// The formula needs to create a memory variable to allow for comparison.
// Add the resulting variable name to be the resulting variable when the
// formula is executed
theFormula_lcl = "theResult_lcl = " || theFormula_lcl || ";";
// Successive Approximation will be used to get the back transform
// Use the min and max of the original column to start the approximations
theMax = Col Max(as column(theColumn) );
theMin = Col Min( as column(theColumn) );
// Loop through the approximations for up to 100 loops to find the value
For( i = 1, i <= 5000, i++,
_X_ = Mean( theMax, theMin );
//_X_ = thetarget_lcl;
Eval( Parse( theFormula_lcl ) );
If(
theResult_lcl > theTarget_lcl, theMax = _X_,
theResult_lcl < theTarget_lcl, theMin = _X_,
Break()
);
);
neb1 << set( _X_ );
// Display the findings in the log
Show( i,_x_,theTarget_lcl, theResult_lcl);
// Find the back transform of the calculated mean of the transformed distribution
//theTargetCol = Column( dt, N Cols( dt ) ) << get name;
theFormula_ucl = Char( As Column( dt, theTargetCol ) << get formula );
//theTarget_ucl = nebvalue2;
// Change the reference to the original column used in the transformation to _X_
// so it can be used in the back transform
Substitute Into( theFormula_ucl, ":"|| theColumn[1], "_X_" );
// The formula needs to create a memory variable to allow for comparison.
// Add the resulting variable name to be the resulting variable when the
// formula is executed
theFormula_ucl = "theResult_ucl = " || theFormula_ucl || ";";
// Successive Approximation will be used to get the back transform
// Use the min and max of the original column to start the approximations
theMax = Col Max(as column(theColumn) );
theMin = Col Min( as column(theColumn) );
// Loop through the approximations for up to 100 loops to find the value
For( i = 1, i <= 15000, i++,
_X_ = Mean( theMax, theMin );
//_X_ = thetarget_ucl;
Eval( Parse( theFormula_ucl ) );
If(
theResult_ucl > theTarget_ucl, theMax = _X_,
theResult_ucl < theTarget_ucl, theMin = _X_,
Break()
);
);
// Display the findings in the log
Show( i,_x_,theTarget_ucl, theResult_ucl);
neb2 << set( _X_ );
neb3<<set(theResult_lcl);
neb4<<set(theResult_ucl);
),
Vlistbox(
textbox("LCL"
),
textbox("UCL"
)
),
Vlistbox(
neb1=numbereditbox(
),
neb2=numbereditbox(
),
Vlistbox(
neb3=numbereditbox(
),
neb4=numbereditbox(
)
)
)
)
)
);
Jim