cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Try the Materials Informatics Toolkit, which is designed to easily handle SMILES data. This and other helpful add-ins are available in the JMP® Marketplace
Choose Language Hide Translation Bar
Neo
Neo
Level VI

Continue or abort based on user input.

Below is a small script to check user input (below) which I plan to place in another main script. I want to proceed with the rest of the main script if the user selects OK and abort if the user clicks Cancel in the user input script. How to achieve this?.

mywin1 = new window("YOU HAVE SELECTED:", << modal,
     
      //ID = "part123";
      //flavour = "Red";
      //TestYear = "2021"; 
      //LimFileName  = "EVTeg";
      
      text box("Wafer ID: "||ID||" \!nProduct Type: "||flavour||" \!nTest year: "||TestYear||" \!nLimts File: "||LimFileName||" \!nDo you wish to continue?"),

      button box("Yes", which_button = "OK"),

      button box("No", which_button = "Cancel"),

);

The commented lines were just to test this piece of code. These would be supplied from the main script above the test user input script. 

When it's too good to be true, it's neither
1 ACCEPTED SOLUTION

Accepted Solutions
jthi
Super User

Re: Continue or abort based on user input.

One option would be to use <<return result with <<modal and then check the value of mywin1["Button"] after modal is closed

Names Default To Here(1);

ID = "part123";
flavour = "Red";
TestYear = "2021"; 
LimFileName  = "EVTeg";

mywin1 = New Window("YOU HAVE SELECTED:",
	<<modal,
	<<Return Result,
	Text Box(
		"Wafer ID: " || ID || " \!nProduct Type: " || flavour || " \!nTest year: " || TestYear ||
		" \!nLimts File: " || LimFileName || " \!nDo you wish to continue?"
	), 
	Button Box("Yes", which_button = "OK"), 
	Button Box("No", which_button = "Cancel"), 
);
show(mywin1); //debug print
If(mywin1["Button"] != 1,
	Show("cancel");
	throw("cancel pressed");
	//stop();
);
Show("ok");
Show("continue execution");

Also <<On validate(expr) and << On Close(expr) might be helpful

-Jarmo

View solution in original post

3 REPLIES 3
jthi
Super User

Re: Continue or abort based on user input.

One option would be to use <<return result with <<modal and then check the value of mywin1["Button"] after modal is closed

Names Default To Here(1);

ID = "part123";
flavour = "Red";
TestYear = "2021"; 
LimFileName  = "EVTeg";

mywin1 = New Window("YOU HAVE SELECTED:",
	<<modal,
	<<Return Result,
	Text Box(
		"Wafer ID: " || ID || " \!nProduct Type: " || flavour || " \!nTest year: " || TestYear ||
		" \!nLimts File: " || LimFileName || " \!nDo you wish to continue?"
	), 
	Button Box("Yes", which_button = "OK"), 
	Button Box("No", which_button = "Cancel"), 
);
show(mywin1); //debug print
If(mywin1["Button"] != 1,
	Show("cancel");
	throw("cancel pressed");
	//stop();
);
Show("ok");
Show("continue execution");

Also <<On validate(expr) and << On Close(expr) might be helpful

-Jarmo
Neo
Neo
Level VI

Re: Continue or abort based on user input.

@jthi 

Thanks. This seems to be working.

While I test the actual code I have one more question (not related to the OP). How do I make the following text bold?

YOU HAVE SELETED:

Wafer ID:
Product Type:
Test year:
Limts File:

When it's too good to be true, it's neither
txnelson
Super User

Re: Continue or abort based on user input.

Use the Set Font Style message....see below

Names Default To Here(1);

ID = "part123";
flavour = "Red";
TestYear = "2021"; 
LimFileName  = "EVTeg";

mywin1 = New Window("YOU HAVE SELECTED:",
	<<modal,
	<<Return Result,
	tb = Text Box(
		"Wafer ID: " || ID || " \!nProduct Type: " || flavour || " \!nTest year: " || TestYear ||
		" \!nLimts File: " || LimFileName || " \!nDo you wish to continue?"
	), 
	Button Box("Yes", which_button = "OK"), 
	Button Box("No", which_button = "Cancel"),
	tb << set font style("bold");
);
show(mywin1); //debug print
If(mywin1["Button"] != 1,
	Show("cancel");
	throw("cancel pressed");
	//stop();
);
Show("ok");
Show("continue execution");

All of the messages that can be sent to the various objects are defined in the Scripting Index.

Jim