Page 1 of 1

stopping all running scripts |SOLVED|

Posted: Fri Jul 04, 2014 10:12 am
by Johan_VH
Hi all,

I have been a Flash and Director developer for years, and just this week bettered my life and switched to LiveCode. The speed at which I can get things done baffles me by the way!

But as is to be expected, there are some hickups too. In Flash you can test a script by pressing ctrl-enter for instance, you get your program in a window and if you close that window you effectively halt all scripts. In Director, which behaves more like livecode, you have a play and stop button. Pressing the stop button halts all scripts too. But in LiveCode I run into a problem. When I test it, some scripts which execute at standard intervals keep running, consequently LiveCode gets reaaaaaaaal slow and I have to go to the script and put in a breakpoint in order to be able to stop executing it. So far that works, but as my project will grow that won't be practical anymore. Is there a way to just stop all the scripts from executing? A command that I can enter in the message box or something?

Thanks in advance,

Johan

Re: stopping all running scripts

Posted: Fri Jul 04, 2014 10:44 am
by bangkok
"standard intervals"... you mean you send messages "in time" ?

To delete all pending messages, in this case :

Code: Select all

  put the pendingmessages into myMsgs
   repeat for each line myMsg in myMsgs
      cancel item 1 of myMsg
   end repeat

Re: stopping all running scripts

Posted: Fri Jul 04, 2014 12:01 pm
by Johan_VH
Since I'm new to LiveCode, I'm probably not coding in the best way possible, I'm not using timers (yet)....

I have a handler, it executes and then have it check if it should execute again. If so, it goes to another handler that calls the first handler again.
I noticed that just calling the handler again from within the handler caused LiveCode to execute again and again, thus crashing LiveCode. I tried to solve this with the 'exit' command, but it didn't do the trick.

Code: Select all

on animateScreensaver
   switch (pSwitch)
      case 1
         move image "logo.png" from 600,394 to 200,394 in 1 seconds
         move field "Titel_txt" from 85,389 to 705,389 in 1 seconds
         wait 1 second
         move image "logo.png" from 200,394 to 600,394 in 1 seconds
         move field "Titel_txt" from 705,389 to 85,389 in 1 seconds
         put 2 into pSwitch
         if gScreenSaverActive=1 then
          continueAnimation
         else
             go stack "game"
         end if
         break
      case 2
         move image "scan_logo.png" from 600,392 to 320,392 in 1 seconds
          move field "Titel_txt" from 85,389 to 705,389 in 1 seconds
         wait 1 second
         move image "scan_logo.png" from 320,392 to 600,392 in 1 seconds
         move field "Titel_txt" from 705,389 to 85,389 in 1 seconds
         put 1 into pSwitch
         if gScreenSaverActive=1 then
            continueAnimation
         else
           go stack "game"
         end if
         break
      case 3
         break
   end switch
end animateScreensaver

Code: Select all

on continueAnimation
    wait 1 second
   animateScreensaver
end continueAnimation
gScreenSaverActive is set to 0 when an RFID is scanned and is received by an xml socket. I now have to go through the motions to stop it, a shortcut that just halts all scripts would be easier...

Re: stopping all running scripts

Posted: Fri Jul 04, 2014 1:10 pm
by Klaus
Hi Johan,

check "movingcontrols" in the dictionary, this will give you a list of all controls that are currently (still) moving.
Then you can stop their movement similar to cancelling the pendingmessages:

Code: Select all

...
  put the movingcontrols into tMCs
   repeat for each line tMC in tMCs
     stop moving tMC
   end repeat
...
Best

Klaus

Re: stopping all running scripts

Posted: Fri Jul 04, 2014 4:33 pm
by Johan_VH
Thank you!

Re: stopping all running scripts

Posted: Fri Jul 04, 2014 9:23 pm
by paul_gr
Klaus wrote: check "movingcontrols" in the dictionary, this will give you a list of all controls that are currently (still) moving.
After 8 years I've never heard of it, must be a lot more I don't know...

Thanks for that Klaus.

Paul

Re: stopping all running scripts |SOLVED|

Posted: Sun Mar 20, 2016 9:04 pm
by erikhans08
Keep Message Box (Pending Messages) open. Click on "Cancel All"