cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
JMP is taking Discovery online, April 16 and 18. Register today and join us for interactive sessions featuring popular presentation topics, networking, and discussions with the experts.
Choose Language Hide Translation Bar
888kk888
Level II

How to execute a portion of a script based on USER selection on a pop out box

Hi,  I have a really basic question:  I am running the following script but I want to have a user interface that allows the user to select an option.  Based on the option that is selected, a portion of the script is run.  Can you kindly help with that or refer to an example which I can use in my script. 

Below is the not the complete script, it is just to highlight that the script has multiple portions, some are just Overlay plots and some summaries or joining. I want to know how to can I execute portion of a script if a specific option is selected by the user and how to end this if user cancels or clicks on "x" on the pop-up window. 

 

 

//***********
overlayPlot = {"ByTestHead","ByDuts","EntireFleetOn1Dut" };
 
 
Options = new window("Overlay Plot",<<modal,
                    Text box("Choose Overlay Plot Type", <<set width (180)),
                    cb1 = combo Box( overlayPlot ),
             h list box(
                    Button Box( "OK"),
                    Button Box( "Cancel")
       ),
);
 
//Cancel script if Cancel Button selected
BB = Options["Button"];
if(BB==-1, throw(),);
 
 
//If "ByDuts" is slected by user run this section
 
 //***********Overlay By DUT**************
 
      
jrnl1= Overlay Plot(
       X( :Name( "Min(X)" ) ),
       Y( :Name( "Min(Y)" ) ),
       Grouping( :DUT ),
       Overlay Groups( Group[1] << Group Color( 32 ) << Group Marker( 0 ) ),
       SendToReport(
             Dispatch( {}, "Overlay Plot", OutlineBox, {Set Title( "This one" )} ),
             Dispatch(
                    {},
                    "Overlay Plot Graph",
                    FrameBox( 14 ),
                    {Frame Size( 660, 570 )}
             ),
             Dispatch(
                    {},
                    "",
                    LegendBox,
                    {Set Title( "Groups" ), Orientation( "Vertical" )}
             )
       )
);
 
jrnl1 <<journal;
 
//If "ByTestHead" is slected by user run this section
//**************By Test Head******************
 
 
jrnl2= Overlay Plot(
       X( :Name( "Min(X)" ) ),
       Y( :Name( "Min(Y)" ) ),
       Grouping( :DUT ),
       Overlay Groups( Group[1] << Group Color( 32 ) << Group Marker( 0 ) ),
       SendToReport(
             Dispatch( {}, "Overlay Plot", OutlineBox, {Set Title( "This one" )} ),
             Dispatch(
                    {},
                    "Overlay Plot Graph",
                    FrameBox( 14 ),
                    {Frame Size( 660, 570 )}
             ),
             Dispatch(
                    {},
                    "",
                    LegendBox,
                    {Set Title( "Groups" ), Orientation( "Vertical" )}
             )
       )
);
 
jrnl2 <<journal;
 
 
 
//If "EntireFleetOn1Dut" is slected by user run this section
//*****************By DiePin Burn Count**************
 
 
kb4=Data Table( "damagehistory" );
kb4<< Summary(
       Group( :DiePin ),
       Freq( "None" ),
       Weight( "None" ),
       output table name( "DiePinBurnCount" )
);
 
kb5=Data Table( "Dutref" );
kb5 << Join(
       With( Data Table( "DiePinBurnCount" ) ),
       Select( :DiePin, :Name( "Min(X)" ), :Name( "Min(Y)" ) ),
       SelectWith( :N Rows ),
       By Matching Columns( :DiePin = :DiePin ),
       Drop multiples( 0, 0 ),
       Include Nonmatches( 1, 1 ),
       Preserve main table order( 1 ),
       Output Table( "OverlayByDiePinBurn" )
);
kb6=Data Table ("OverlayByDiePinBurn");
 
kb6 <<New Column("# of Times Failing", Numeric, "Continuous", Format("Best", 12), Formula(If(Is Missing(:N Rows), 0, :N Rows)));
 
Overlay Plot(
       X( :Name( "Min(X)" ) ),
       Y( :Name( "Min(Y)" ) ),
       Grouping( :Name( "# of Times Failing" ) ),
       Overlay Groups(
             Group[1] << Group Color( 80 ) << Group Marker( 0 ),
             Group[2] << Group Color( 80 ),
             Group[3] << Group Color( 73 ),
             Group[4] << Group Color( 73 ),
             Group[5] << Group Color( 73 ),
             Group[6] << Group Color( 73 ),
             Group[7] << Group Color( 73 ),
             Group[8] << Group Color( 70 ),
             Group[9] << Group Color( 70 ),
             Group[10] << Group Color( 70 ),
             Group[11] << Group Color( 70 ),
             Group[12] << Group Color( 70 ),
             Group[13] << Group Color( 70 ),
             Group[14] << Group Color( 70 ),
             Group[15] << Group Color( 38 ),
             Group[16] << Group Color( 38 ),
             Group[17] << Group Color( 38 ),
             Group[18] << Group Color( 35 ),
             Group[19] << Group Color( 3 ),
             Group[20] << Group Color( 3 ),
             Group[21] << Group Color( 19 ),
             Group[22] << Group Color( 19 ),
             Group[23] << Group Color( 51 ),
             Group[24] << Group Color( 51 )
       ),
       SendToReport(
             Dispatch( {}, "Overlay Plot", OutlineBox, {Set Title( "What else" )} ),
             Dispatch(
                    {},
                    "Overlay Plot Graph",
                    FrameBox( 25 ),
                    {Frame Size( 719, 632 )}
             ),
             Dispatch(
                    {},
                    "",
                    LegendBox,
                    {Set Title( "Groups" ), Orientation( "Vertical" )}
             )
       )
);

 

3 ACCEPTED SOLUTIONS

Accepted Solutions
gzmorgan0
Super User (Alumni)

Re: How to execute a portion of a script based on USER selection on a pop out box

Hi. I have a simple recommendation: use expressions to store portions of your script.

 

Expressions can be entire scripts. Another option is to use Include() files.

 

You did not say which version of JMP you are using. I attached two scripts, one for version 12 and another for version 13, that selects different expressions. The one for version 12 might also work on version 11.

 

These scripts prompt the user and runs different expressions based upon user input or cancel. The Expressions are simple caption boxes.

 

Hope this helps.

 

 

View solution in original post

shoffmeister
Level V

Re: How to execute a portion of a script based on USER selection on a pop out box

You might want to look at this blogpost: https://community.jmp.com/t5/JMPer-Cable/How-to-create-a-JMP-user-interface-using-display-boxes-in-J...

 

Much more info about user interfaces in JMP is of course provided in the JMP Scripting Guide (in JMP go to the main menu => Help => Books => Scripting Guide). You will be interested in chapter 11 "Display Trees". 

 

Here is a very simple example in JSL:

// User Interface using radio buttons
ui = New Window( "Chose an option",
	<<Modal,
	user choice box = Radio Box( {"A", "B"} ),
	Button Box( "Ok", user choice = user choice box << Get Selected ) // The second argument is executed when the user presses the "OK"-button
);

// Now do something depending on the users choice
If( user choice == "A",
	New Window( "Result", Text Box( "You chose A!" ) ),
	New Window( "Result", Text Box( "You chose B!" ) )
);

 

View solution in original post

888kk888
Level II

Re: How to execute a portion of a script based on USER selection on a pop out box

thanks a lot Guys. Both were very helpful.

View solution in original post

5 REPLIES 5
gzmorgan0
Super User (Alumni)

Re: How to execute a portion of a script based on USER selection on a pop out box

Hi. I have a simple recommendation: use expressions to store portions of your script.

 

Expressions can be entire scripts. Another option is to use Include() files.

 

You did not say which version of JMP you are using. I attached two scripts, one for version 12 and another for version 13, that selects different expressions. The one for version 12 might also work on version 11.

 

These scripts prompt the user and runs different expressions based upon user input or cancel. The Expressions are simple caption boxes.

 

Hope this helps.

 

 

888kk888
Level II

Re: How to execute a portion of a script based on USER selection on a pop out box

thanks a lot Guys. Both were very helpful.

shoffmeister
Level V

Re: How to execute a portion of a script based on USER selection on a pop out box

You might want to look at this blogpost: https://community.jmp.com/t5/JMPer-Cable/How-to-create-a-JMP-user-interface-using-display-boxes-in-J...

 

Much more info about user interfaces in JMP is of course provided in the JMP Scripting Guide (in JMP go to the main menu => Help => Books => Scripting Guide). You will be interested in chapter 11 "Display Trees". 

 

Here is a very simple example in JSL:

// User Interface using radio buttons
ui = New Window( "Chose an option",
	<<Modal,
	user choice box = Radio Box( {"A", "B"} ),
	Button Box( "Ok", user choice = user choice box << Get Selected ) // The second argument is executed when the user presses the "OK"-button
);

// Now do something depending on the users choice
If( user choice == "A",
	New Window( "Result", Text Box( "You chose A!" ) ),
	New Window( "Result", Text Box( "You chose B!" ) )
);

 

888kk888
Level II

Re: How to execute a portion of a script based on USER selection on a pop out box

I have a follow-up question.

Now what I want is the option box to remain open even after making a selection so that I can make another choice if I want to.

How can I script it in shuch a way that dialog box closes only when I cancel?

gzmorgan0
Super User (Alumni)

Re: How to execute a portion of a script based on USER selection on a pop out box

Here is a very simple example using a Radio Box. Depending upon the user selection values are added to a table.

The <<set function is run whenever a selection is made. In this example, the user can select the same button may times.

"this" refers to the display box object.  Sending a message to "this" must be a valid message for a radio box.   

 

It is likely that your example is a menu of options. You can add buttons and items to a JMP platform window.  

Names Default To Here( 1 );
testTable = new Table("get values", New Column("User Selections", numeric));
New Window( "Example",
	Radio Box({"press one", "press two", "press 3"},
		<<setFunction(
			Function(
				{this/* functions specified with SetFunction get 'this' display box */
				}, {_xx, nr}, //local values
				_xx = choose(this << get, Random Integer(1,10), 100*Random Integer(1,3),
				 Ceiling(1000*(Random Uniform())));
				 testTable << Add Row(1);
				 nr = nrow(testTable);
				 :User Selections[nr]=_xx
			)
		)
	)
);

The dialog box persists, but it is not modal, meaning it does not lock out other JMP actions while it is open. 

I hope you find this example informative.