Subscribe Bookmark RSS Feed

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

antoinesofradir

Community Trekker

Joined:

Apr 26, 2013

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

Joined:

Jun 23, 2011

Solution

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

  )

);

3 REPLIES
ms

Super User

Joined:

Jun 23, 2011

Solution

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

Community Trekker

Joined:

Apr 26, 2013

Good Job ! it works !

Thank you very much !

MS number one !

gwenicat

Community Trekker

Joined:

Aug 28, 2014

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

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