Share your ideas for the JMP Scripting Unsession at Discovery Summit by September 17th. We hope to see you there!
Choose Language Hide Translation Bar
Highlighted
BrianK
Level I

Passing a variable into a cusum chart

Hi there,

 

In the simple script below, how do I pass the variables varTarget and varSigma into the cusum creation? 

 

 

dt = Open( "$SAMPLE_DATA/Quality Control/Engine Temperature Sensor.jmp" );

varTarget = 100;
varSigma = 10;

dt << CUSUM Control Chart(
    Y( :Y ),
    Target( varTarget ),
    Sigma( varSigma ),
    SendToReport(
        Dispatch( {"CUSUM Chart"}, "2", ScaleBox, {Min( -7.5 ), Max( 10 ), Inc( 5 ), Minor Ticks( 1 )} )
    )
);

 

2 REPLIES 2
Highlighted

Re: Passing a variable into a cusum chart

I thought that I could use Eval Expr() function with the variables as arguments but it didn't work here. Anyway, I usually use this approach based on substituting parts of an expression.

 

Names Default To Here( 1 );

dt = Open( "$SAMPLE_DATA/Quality Control/Engine Temperature Sensor.jmp" );

varTarget = 100;
varSigma = 10;

Eval(
	Substitute(
		Expr(
			dt << CUSUM Control Chart(
				Y( :Y ),
				Target( ttt ),
				Sigma( sss ),
				SendToReport(
					Dispatch( {"CUSUM Chart"}, "2", ScaleBox, {Min( -7.5 ), Max( 10 ), Inc( 5 ), Minor Ticks( 1 )} )
				)
			)
		),
		Expr( ttt ), varTarget,
		Expr( sss ), varSigma
	)
);
Learn it once, use it forever!
Highlighted
ih
ih
Level VII

Re: Passing a variable into a cusum chart

Here is how to do it with Eval Expr:

 

Eval(Eval Expr(
	dt << CUSUM Control Chart(
		Y( :Y ),
		Target( Expr( varTarget ) ),
		Sigma( Expr( varSigma ) ),
		SendToReport(
			Dispatch( {"CUSUM Chart"}, "2", ScaleBox, {Min( -7.5 ), Max( 10 ), Inc( 5 ), Minor Ticks( 1 )} )
		)
	)
));

This link shows a few other methods to do the same thing.

Article Labels