stopping all running scripts |SOLVED|

Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller

Post Reply
Johan_VH
Posts: 67
Joined: Fri Mar 28, 2014 2:46 pm

stopping all running scripts |SOLVED|

Post by Johan_VH » Fri Jul 04, 2014 10:12 am

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
Last edited by Johan_VH on Fri Jul 04, 2014 4:34 pm, edited 1 time in total.

bangkok
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 937
Joined: Fri Aug 15, 2008 7:15 am

Re: stopping all running scripts

Post by bangkok » Fri Jul 04, 2014 10:44 am

"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

Johan_VH
Posts: 67
Joined: Fri Mar 28, 2014 2:46 pm

Re: stopping all running scripts

Post by Johan_VH » Fri Jul 04, 2014 12:01 pm

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...

Klaus
Posts: 14199
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: stopping all running scripts

Post by Klaus » Fri Jul 04, 2014 1:10 pm

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

Johan_VH
Posts: 67
Joined: Fri Mar 28, 2014 2:46 pm

Re: stopping all running scripts

Post by Johan_VH » Fri Jul 04, 2014 4:33 pm

Thank you!

paul_gr
Posts: 319
Joined: Fri Dec 08, 2006 7:38 pm

Re: stopping all running scripts

Post by paul_gr » Fri Jul 04, 2014 9:23 pm

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

erikhans08
Posts: 87
Joined: Wed Mar 25, 2015 2:01 am

Re: stopping all running scripts |SOLVED|

Post by erikhans08 » Sun Mar 20, 2016 9:04 pm

Keep Message Box (Pending Messages) open. Click on "Cancel All"

Post Reply