cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
  • Learn how to build custom Python data connectors and further customize JMP’s Data Connector Framework with the Python Data Connector Demo, available now in the JMP Marketplace!
  • See how to create experiments to support product design and ID useful product features. Register for June 12 webinar, 2pm US Eastern Time.

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