It’s World Statistics Day! To honor the theme of the day, the JMP User Community is having conversations about the importance of trust in statistics and data. And we want to hear from you! Tell us the steps you take to ensure that your data is trustworthy.
Choose Language Hide Translation Bar
Highlighted
hans_deroos
Level II

The use of Throw( in scripting

I  use Throw() in my programs to stop the execution for that particular part of the program. This still works in JMP 13 but I sometimes get a new window with a JMP Alert.  I can't seem to simulate the problem - It happens in a User Window - the program sees a problem, the program sends a Caption and executes a Throw().  In earlier version I only got the Caption now I sometimes get an Alert window as well.  I thought Throw() just stops execution. I can use text in the Throw("Hello") and it will in this case get a JMP Alert with the text - if executed on its own I get only the text in the log.  I'm not sure what to expect when.  Can anybody help.

2 ACCEPTED SOLUTIONS

Accepted Solutions
Highlighted
Craige_Hales
Staff (Retired)

Re: The use of Throw( in scripting

Alert dialog triggered by JSL throw in Interactive modeAlert dialog triggered by JSL throw in Interactive mode

When JSL runs from a button script it is running in interactive mode and produces alert dialogs when JMP thinks you should know what happened. If you run a script by submitting it, JSL runs in batch mode and just sends alerts to the log. I think in your case you probably want to use stop() rather than throw("msg").

When you submit this script, it runs in batch mode and brings up a window. When you click a button in the window, the button script runs interactively.

newwindow("x",
buttonbox("throw(err msg)",setscript(print(1);throw("this is an error message");print(2))),
buttonbox("throw",setscript(print(3);throw();print(4))),
buttonbox("stop",setscript(print(5);stop();print(6))),	
)

For each of the buttons, only the first number is printed in the log because the script stops. 

Craige

View solution in original post

Highlighted
hans_deroos
Level II

Re: The use of Throw( in scripting

Thanks Craige - exactly what I need - the Stop() function.  I can't get it the Sctipt Manual though.

I would expect that the 'throw' button in your example would display an empty Alert like below.  This is what I get in my own program - as you said it is in an interactive environment JMP Alert.jpg

View solution in original post

4 REPLIES 4
Highlighted
Craige_Hales
Staff (Retired)

Re: The use of Throw( in scripting

Alert dialog triggered by JSL throw in Interactive modeAlert dialog triggered by JSL throw in Interactive mode

When JSL runs from a button script it is running in interactive mode and produces alert dialogs when JMP thinks you should know what happened. If you run a script by submitting it, JSL runs in batch mode and just sends alerts to the log. I think in your case you probably want to use stop() rather than throw("msg").

When you submit this script, it runs in batch mode and brings up a window. When you click a button in the window, the button script runs interactively.

newwindow("x",
buttonbox("throw(err msg)",setscript(print(1);throw("this is an error message");print(2))),
buttonbox("throw",setscript(print(3);throw();print(4))),
buttonbox("stop",setscript(print(5);stop();print(6))),	
)

For each of the buttons, only the first number is printed in the log because the script stops. 

Craige

View solution in original post

Highlighted
hans_deroos
Level II

Re: The use of Throw( in scripting

Thanks Craige - exactly what I need - the Stop() function.  I can't get it the Sctipt Manual though.

I would expect that the 'throw' button in your example would display an empty Alert like below.  This is what I get in my own program - as you said it is in an interactive environment JMP Alert.jpg

View solution in original post

Highlighted
vince_faller
Super User

Re: The use of Throw( in scripting

Another thing about stop().  It seems to only stop the script in the displaybox that holds it.

dt = open("$SAMPLE_DATA\Big Class.jmp");
newwindow("x", <<modal,
	lb = collistbox(dt, all),
	textbox("don't select anything"),
	buttonbox("OK", 
		n = nitems(lb << Get Selected);
		if(n==0, stop());
		print("Button Stopped");
	)	
);

print("Main Script not stopped");

 

Vince Faller - Predictum
Highlighted
hans_deroos
Level II

Re: The use of Throw( in scripting

The same is true for Throw(

Article Labels

    There are no labels assigned to this post.