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
miguello
Level VI

How to close App using JSL?

All, 

 

I cannot find a way to do the following:

 

Let's say I have an App that is in the form of AddIn.

For it to successfully run it needs some conditions met. When they are not I want to create a modal window with description what's needed to run the App and on hitting "OK" button close the App (not JMP though).

How can I close a running App within this App using JSL (I'm going to put it as script to Butotn Box with "OK").

 

Thanks, 

M.

1 ACCEPTED SOLUTION

Accepted Solutions

Re: How to close App using JSL?

The JMP Application has a built-in script that would be a good place for checks like these.  The Application workflow is:

 

Run Application Script;

for each module (

   if (module is autolaunch,

      module<<Create Instance()

   );

);

 

One way to add pre-launch checks for your applications would be:

 

1. Turn off Autolaunch for all modules (select in object panel, toggle off Auto Launch in properties)

2. On the script tab for the Application:

 

okToLaunch = /* insert conditions */

if (okToLaunch,

   Module1 << Create Instance,

   /* else show error dialog and exit */

);

View solution in original post

8 REPLIES 8
txnelson
Super User

Re: How to close App using JSL?

I typically just close the windows associated with the application

obj << close window;
Jim
miguello
Level VI

Re: How to close App using JSL?

Ok, I tried the following:

Created a blank App, default Module1 name. Created one button with the following code:

Button1Press=Function({this},
	// This function is called when the button is pressed
	name = this << Get Button Name;
	show("Trying to close App");
	thisModuleInstance << Close Window;
	thisApplication << Close Window;
	Module1 << Close Window;

);

None of the three options worked.

 

How do I get the name of the Application window then?

 

Thanks, 

M.

txnelson
Super User

Re: How to close App using JSL?

Try this:

window(" - Application")<< close window;

You can specify either the window name, or window number, or if you created the window and have a pointer to the window, you can just pass the << close window; message to it.

You can use this little piece of code to find out all of the window names

i = 1;
While( Window( i ) << get window title != {},
	Show( Window( i ) << get window title );
	i++;
);
Jim

Re: How to close App using JSL?

The JMP Application has a built-in script that would be a good place for checks like these.  The Application workflow is:

 

Run Application Script;

for each module (

   if (module is autolaunch,

      module<<Create Instance()

   );

);

 

One way to add pre-launch checks for your applications would be:

 

1. Turn off Autolaunch for all modules (select in object panel, toggle off Auto Launch in properties)

2. On the script tab for the Application:

 

okToLaunch = /* insert conditions */

if (okToLaunch,

   Module1 << Create Instance,

   /* else show error dialog and exit */

);

miguello
Level VI

Re: How to close App using JSL?

Thanks! This solves the problem of pre-launch checks.

 

However, it would still be useful to know how to close an App window.

Closing it by the title as was suggested eariler does not seem to be reliable as title can change (and I do change title in my scripts for various windows).

Is there any way to get a handle on the main App window?

 

Thanks, 

M

 

Re: How to close App using JSL?

One thing to keep in mind is that every window created by a JMP Application is associated with a Module Instance.  In the script for the module, you can do something like:

 

(thisModuleInstance << Get Box) << Close Window;

 

You could just as well use any of the boxes that define the content of the module.  You will see that this approach is used in the sample JMP Application "Launcher With Report".  In this example, a launch window is created in one module to collect input, and on "OK" the launch window is closed and the report window is created.

jsdejmp
Level II

Re: How to close App using JSL?

This is what I needed. Since 'thisModuleInstance' is reserved, it would be helpful to add some documentation when a user creates a new application, eg

jsdejmp_1-1635280612145.png

 

tbidwell
Level III

Re: How to close App using JSL?

Thank you for that information and example.  This exactly what I've been searching the forums to do!