cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Browse apps to extend the software in the new JMP Marketplace
Choose Language Hide Translation Bar
nikles
Level VI

Get "On Close" script?

Hi.  In JMP there's a way to create a script that automatically executes when the window or table is closed using the "On Close()" command.  Is there any way to return the script without executing?  That is, I'm looking for a command something like "dt << Get On Close". 

 

My specifics:

JMP Pro 16.2.0

macOS Monterey 12.5
 
Thanks.
7 REPLIES 7
txnelson
Super User

Re: Get "On Close" script?

In your On Close() function for the given data table, you can use an Include() to bring in a script and run it.  If you just want to just get the script, you can use Load Text File().

Jim
Craige_Hales
Super User

Re: Get "On Close" script?

After trying a few things, I believe the on close script is write only and Jim's solution is the best choice.

Craige
jthi
Super User

Re: Get "On Close" script?

Other option would be to evaluate the script into On Close, then you could access it with the saved expression you have

Names Default To Here(1);
//This message applies to all display box objects
dt = Open("$SAMPLE_DATA/Big Class.jmp");
on_close_expr = Expr(Show(1));

Eval(EvalExpr(dt << On Close(
	Expr(on_close_expr)
)));

Show(Name Expr(on_close_expr));
-Jarmo
nikles
Level VI

Re: Get "On Close" script?

Thanks for the suggestions everyone, but allow me to clarify.  I have a script that assigns an << On Close expression to a table, among other things.  My issue is that when I subsequently close the table by hand, the on-close expression is not executing the way I intended.  As part of my debugging, I'm trying to read back the table's on-close script independently to confirm the script is there.  

 

I can already inspect the original on-close expression that I'm assigning to the table in my larger script, but now want to confirm that when the table is closed, JMP sees the same expression I wrote.

Craige_Hales
Super User

Re: Get "On Close" script?

  • I believe it is write-only. No way to read it back.
  • I don't think JMP is changing your script.
  • You might use @jthi idea to make an expression e of the main body, then use <<OnClose( show(char(nameexpr(e))); eval(e); 1 )
  • If your script depends on globals, you might need to use the evalexpr(...expr(...) ) technique to capture them.
Craige
jthi
Super User

Re: Get "On Close" script?

Maybe you could try setting some very simple << On Close expression just to test it out or use << On Close expression which will prevent the closing of window, like example from Scripting Index:

Names Default To Here(1);
//This message applies to all display box objects
w = Open("$SAMPLE_DATA/Big Class.jmp");
w << On Close(
	// Modal dialogs return Button(1) if OK is pressed, Button(-1) if canceled
	New Window("Are you sure?",
		<<modal,
		V List Box(
			Text Box("Press OK to allow the window to close"),
			H List Box(Button Box("OK"), Button Box("Cancel"))
		)
	)["button"] == 1
);
-Jarmo

Re: Get "On Close" script?

Hello, thank you for the idea. I can confirm that your suggestion of a dt << Get On Close will be available in a future version of JMP. (JMP 18 is likely).