取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 
  • 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.
选择语言 隐藏翻译栏
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 个已接受解答

已接受的解答
Craige_Hales
Super User

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

在原帖中查看解决方案

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

在原帖中查看解决方案

4 条回复4
Craige_Hales
Super User

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
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

vince_faller
Super User (Alumni)

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
hans_deroos
Level II

Re: The use of Throw( in scripting

The same is true for Throw(

推荐文章