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
lisamaley
Level III

User input for matched pair script

I would like to create a JMP script for matched pairs, where the user would input the columns for the matches pairs then I could get selected columns that was entered.

 

so something like

 

dt=current data table();

matched pairs();

Y, Paired Response << Get Selected;

 

Then I want to use the columns selected in my own formulas.  But I cannot figure out how to get the columns selected.

 

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
lisamaley
Level III

Re: User input for matched pair script

I just did this:

 

dt= current data table();

Matched Pairs();

 

// find Matched Pairs platform and get expression for it

window = Get Window List();

For( w = 1, w <= N Items( window ), w++,

title = window[w] << Get Window Title;

If( Contains( title, "Matched Pairs" ),

obj = window[w][OutlineBox(1)] << Get Scriptable Object;

s = obj << Get Script;

Break();

);

);

 

// isolate Y() named argument

s = Arg( Name Expr( s ), 1 );

n response = N Arg( Name Expr( s ) );

// get data columns in Y role

col ref = List();

For( c = 1, c <= n response, c++,

Insert Into( col ref, Arg( Name Expr( s ), c ) );

);

 

// examine results, or use the column references in the rest of the script for a formula

Show( col ref );

 

And this part is not working, I am getting this error:

 

Cannot subscript display box in access or evaluation of 'window[w][Outline Box(1)]',window[w][/*###*/Outlinebox(1)]

 

I was trying to make sure this part worked before I do the calculations with the columns selected.   

 

View solution in original post

9 REPLIES 9
Highlighted

Re: User input for matched pair script

I interpret your request to mean that the user has launched Matched Pairs already and you want to run a script against it. That is, your script does not ask the user for the columns or launch the platform itself.

 

I cannot find a message that returns the data columns used in the Y role of Matched Pairs. I took an approach where I get the script for the launched platform and then parse it to get the data columns.

 

Names Default to Here( 1 );

// simulate actions by user before running the script
dt = Open( "$SAMPLE_DATA/Big Class.jmp" );
mp = dt << Matched Pairs( Y( :height, :weight ), Reference Frame( 1 ) );

// script begins here
s = mp << Get Script;

y1 = Arg( Arg( Name Expr( s ), 1 ), 1 );
y2 = Arg( Arg( Name Expr( s ), 1 ), 1 );

// examine results, or use the column references in the rest of the script for a formula
Show( y1, y2 );
Learn it once, use it forever!
Highlighted

Re: User input for matched pair script

I realized after I posted a solution that if my interpretation is correct, you will not have a reference to the Matched Pairs object. You will have to find it. Here is an updated version of the script.

 

Names Default to Here( 1 );

// simulate actions by user before running the script
dt = Open( "$SAMPLE_DATA/Big Class.jmp" );
dt << Matched Pairs( Y( :height, :weight ), Reference Frame( 1 ) );

// your script begins here

// find Matched Pairs platform and get expression for it
window = Get Window List();
For( w = 1, w <= N Items( window ), w++,
	title = window[w] << Get Window Title;
	If( Contains( title, "Matched Pair" ),
		obj = window[w][OutlineBox(1)] << Get Scriptable Object;
		s = obj << Get Script;
		Break();
	);
);

// get data columns in Y role
y1 = Arg( Arg( Name Expr( s ), 1 ), 1 );
y2 = Arg( Arg( Name Expr( s ), 1 ), 1 );

// examine results, or use the column references in the rest of the script for a formula
Show( y1, y2 );
Learn it once, use it forever!
Highlighted
lisamaley
Level III

Re: User input for matched pair script

If I am understanding this right, this will work if they put in two Ys.  What if they put in more than two Ys, can you put it in as a list or matrix?  Then cycle through the list?

Highlighted

Re: User input for matched pair script

Names Default to Here( 1 );

// simulate actions by user before running the script
dt = Open( "$SAMPLE_DATA/Fitness.jmp" );
dt << Matched Pairs(
	Y( :Runtime, :RunPulse, :RstPulse, :MaxPulse ),
	Separate Pairs( 0 ),
	Reference Frame( 0 )
);

// your script begins here

// find Matched Pairs platform and get expression for it
window = Get Window List();
For( w = 1, w <= N Items( window ), w++,
	title = window[w] << Get Window Title;
	If( Contains( title, "Matched Pair" ),
		obj = window[w][OutlineBox(1)] << Get Scriptable Object;
		s = obj << Get Script;
		Break();
	);
);

// isolate Y() named argument
s = Arg( Name Expr( s ), 1 );
n response = N Arg( Name Expr( s ) );
// get data columns in Y role
col ref = List();
For( c = 1, c <= n response, c++,
	Insert Into( col ref, Arg( Name Expr( s ), c ) );
);

// examine results, or use the column references in the rest of the script for a formula
Show( col ref );
Learn it once, use it forever!
Highlighted
lisamaley
Level III

Re: User input for matched pair script

I just did this:

 

dt= current data table();

Matched Pairs();

 

// find Matched Pairs platform and get expression for it

window = Get Window List();

For( w = 1, w <= N Items( window ), w++,

title = window[w] << Get Window Title;

If( Contains( title, "Matched Pairs" ),

obj = window[w][OutlineBox(1)] << Get Scriptable Object;

s = obj << Get Script;

Break();

);

);

 

// isolate Y() named argument

s = Arg( Name Expr( s ), 1 );

n response = N Arg( Name Expr( s ) );

// get data columns in Y role

col ref = List();

For( c = 1, c <= n response, c++,

Insert Into( col ref, Arg( Name Expr( s ), c ) );

);

 

// examine results, or use the column references in the rest of the script for a formula

Show( col ref );

 

And this part is not working, I am getting this error:

 

Cannot subscript display box in access or evaluation of 'window[w][Outline Box(1)]',window[w][/*###*/Outlinebox(1)]

 

I was trying to make sure this part worked before I do the calculations with the columns selected.   

 

View solution in original post

Highlighted

Re: User input for matched pair script

I do not understand what you are trying to do. I thought that the user would already have the Matched Pairs platform open before you run your script and you need to discover the data columns in the Y role. Your code (below) will just open the Matched Pairs launch dialog instead:

 

dt = current data table();

Matched Pairs();

 

So there will not be any outline box to reference.

Learn it once, use it forever!
Highlighted
lisamaley
Level III

Re: User input for matched pair script

I am trying to do a script that runs the matched pairs platform, gets the columns they put into matched pairs, then use those columns for additional calculations.

 

 

Highlighted

Re: User input for matched pair script

Usually the script would put up a modal dialog to ask the user to select the columns for analysis. You unload the dialog when the user dismisses it. You now have the columns to launch the platform and continue with other computation.

 

There was a very recent discussion about how to use launch dialog as you did but obtain a reference to the platform and control the evaluation of the rest of the script. I can't find it at the moment...

Learn it once, use it forever!
Highlighted
lisamaley
Level III

Re: User input for matched pair script

I got this working as a two step script.  If you find it, please let me know.  I would like to combine these and make it into an add in.

 

 

Article Labels

    There are no labels assigned to this post.