cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
  • Don’t miss your chance to experience Discovery Summit Europe at our best available rate! Early bird registration through 31 Oct.
  • Graph Builder Toolbar streamlines interactive graphing. Creates shortcuts on Report and GraphBuilder Helpers toolbars. Download and install the extension.
  • JMP will suspend normal business operations for our Rest and Recharge Day on Friday, October 2, 2026.
    Regular business hours will resume on Monday, October 5, 2026.

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