cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Try the Materials Informatics Toolkit, which is designed to easily handle SMILES data. This and other helpful add-ins are available in the JMP® Marketplace
Choose Language Hide Translation Bar
antoinesofradir
Level III

[Jsl] How can i stop a script with a button ?

Hello ! I have a problem (again !)

I would like to close my window thanks to a button box and stop my script.

I used this :

nw = New Window( "Window",

[...]

  V List Box(
        Button Box("Fermer",
        nw << Close Window;

       Stop();
                    )

               )

     );

[...]

The window is closed but my script runs ...

Where is my error ?

Thanks for your help !

1 ACCEPTED SOLUTION

Accepted Solutions
ms
Super User (Alumni) ms
Super User (Alumni)

Re: [Jsl] How can i stop a script with a button ?

I think Stop() needs to be in the main script. Within a button box, Stop() will just terminate execution of the button script.

Try something like this:

stop_flag = 0;

nw = New Window( "Window",

  V List Box(

  Button Box( "Fermer",

  nw << Close Window;

  stop_flag++;

  )

  )

);

For( i = 1, i <= 100, i++,

  If( stop_flag,

  Print("Stopped");Stop(),

  Print( "still running" );

  Wait( 0.5 );

  )

);

View solution in original post

4 REPLIES 4
ms
Super User (Alumni) ms
Super User (Alumni)

Re: [Jsl] How can i stop a script with a button ?

I think Stop() needs to be in the main script. Within a button box, Stop() will just terminate execution of the button script.

Try something like this:

stop_flag = 0;

nw = New Window( "Window",

  V List Box(

  Button Box( "Fermer",

  nw << Close Window;

  stop_flag++;

  )

  )

);

For( i = 1, i <= 100, i++,

  If( stop_flag,

  Print("Stopped");Stop(),

  Print( "still running" );

  Wait( 0.5 );

  )

);

antoinesofradir
Level III

Re: [Jsl] How can i stop a script with a button ?

Good Job ! it works !

Thank you very much !

MS number one !

gwenicat
Level III

Re: [Jsl] How can i stop a script with a button ?

Finally! This worked for me as well. I was going slightly demented...

I can't believe it has to be so convoluted...

hogi
Level XII

Re: [Jsl] How can i stop a script with a button ?

@ms wrote:

... Within a button box, Stop() will just terminate execution of the button script.

right!
important to know:

it's not due to the non-modal window, it's due to the limited influence of stop() on the main script.


I just wondered why this script doesn't manage to stop the script before x=5 is executed ...

[in the real script there are additional buttons which will not stop the code]

 

x=1;
New Window( "Phoenix Viewer",
			<<Type( "Modal Dialog" ),				
				Button Box ("OK", Print("OK");stop();  Print("stopped before"))
			);
//stop();
x=5;	

 

so, even for modal windows, one has to a dummy variable to transfer the info to the main script and stop there.

x=1;
stop_flag=0;

New Window( "Phoenix Viewer",
			<<Type( "Modal Dialog" ),				
				Button Box ("OK", Print("OK");stop_flag++;stop();  Print("stopped before"))
			);
if(stop_flag, stop());
x=5;