cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
  • Image to Table JMP extension imports single or batch images as data tables. Useful to extract curves from pictures or convert image data to curve data to use in analyses like Functional Data Explorer. Download and install the extension.

Discussions

Solve problems, and share tips and tricks with other JMP users.
Choose Language Hide Translation Bar
Jemster
Level III

Stop Code When Cancel Button Pressed

I have some code that allows users to pick several options. If they press OK then the code runs as expected but I can't get the cancel button to cancel the code. Exiting the window also results in the code being run. I would like the user to be able to cancel or exit the window and have that stop the code.

win = New Window( "Customise Analysis",
	<<Modal,
	<<Return Result,
	<<On Validate(x = cb<<Get();
		If( ...
		);
	),
	Text Box("Choose the product"),
	cb = Combo Box(
		{"..."},
	),
	Text Box( "..." ),
	fail_out = Number Edit Box( 100 ),
	Text Box("..."),
	Text Box("..."),
	point_lim = Number Edit Box(2),
	Button Box("OK"),
	Button Box("Cancel"),
);

 

1 ACCEPTED SOLUTION

Accepted Solutions
jthi
Super User

Re: Stop Code When Cancel Button Pressed

One option would be to use the button value returned from the window:

Names Default To Here(1);
nw = New Window("Dialog() example",
	<<Modal,
	<<Return Result,
	V List Box(
		H List Box("Set this value", variable = Number Edit Box(42)),
		H List Box(Button Box("OK"), Button Box("Cancel"))
	)
);

If(nw["Button"] != 1,
	stop();
);
show("continue");
-Jarmo

View solution in original post

1 REPLY 1
jthi
Super User

Re: Stop Code When Cancel Button Pressed

One option would be to use the button value returned from the window:

Names Default To Here(1);
nw = New Window("Dialog() example",
	<<Modal,
	<<Return Result,
	V List Box(
		H List Box("Set this value", variable = Number Edit Box(42)),
		H List Box(Button Box("OK"), Button Box("Cancel"))
	)
);

If(nw["Button"] != 1,
	stop();
);
show("continue");
-Jarmo

Recommended Articles