cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
  • JMP will suspend normal business operations for our Winter Holiday beginning on Wednesday, Dec. 24, 2025, at 5:00 p.m. ET (2:00 p.m. ET for JMP Accounts Receivable).
    Regular business hours will resume at 9:00 a.m. EST on Friday, Jan. 2, 2026.
  • We’re retiring the File Exchange at the end of this year. The JMP Marketplace is now your destination for add-ins and extensions.

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