Re: lingo-l How to stop a loop.
Yep, saw it yesterday thanks again fabrice Kerry Thompson heeft op donderdag 19 september 2002 om 15:49 het volgende geschreven: hi all, got a script than stays looping in a repeat. in some case, the loop takes several seconds to end. But i want to be able to let him stop during the repeat. tried something like this via a button, but its ignored. global stop on somehandler repeat with x = 1 to Myvar if Stop = true Stop = false exit repeat else do your job end repeat end on a button got a stop = true, global stop The repeat loop is hogging the CPU. If you're using a keyDown handler, it will wait until the repeat finishes. I would either change the repeat loop to a frame event, or use on keyPressed. keyPressed will interrupt a loop. Cordially, Kerry Thompson [To remove yourself from this list, or to change to digest mode, go to http://www.penworks.com/lingo-l.cgi To post messages to the list, email [EMAIL PROTECTED] (Problems, email [EMAIL PROTECTED]). Lingo-L is for learning and helping with programming Lingo. Thanks!] [To remove yourself from this list, or to change to digest mode, go to http://www.penworks.com/lingo-l.cgi To post messages to the list, email [EMAIL PROTECTED] (Problems, email [EMAIL PROTECTED]). Lingo-L is for learning and helping with programming Lingo. Thanks!]
Re: lingo-l How to stop a loop.
However, as I and others have pointed out, it is inadvisable to call updateStage continually like this. I agree, but in this particular script, the bar is only once per file updated. to give you an idee, the files are conatining arround 3000 words, wich are checked during the loop and the bar, moves only when a file is open, the next file is then open, checked then closed, again bar progress moves... In my last test with 60 files, i was able to retrieve 30 macht out of those files within a few seconds. The progress bar via updatestage has almost no influence, again on this particular script, i also use the update command rarely. but i must say the timer thing to force an go to the frame and continue the loop, looks very interesting, i definatly will try this one. thanks again for the reply... love this list, for a single question, you get a full academic intruction with all variants and aspects... just great!! Fabrice Robert Tweed heeft op donderdag 19 september 2002 om 19:25 het volgende geschreven: - Original Message - From: Fabrice Closier [EMAIL PROTECTED] yes but i'am using a moviescript.. i just call an handler. the frame script is just on exitframe go to the frame end You could use timers, or create an object to put in the actorList, or add it to exitFrame in your frame script. Just use an if statement so it only runs when you need it. It's easy to avoid the repeat loop, it's simply a question of whether or not you actually need the repeat loop to do something many times per frame, in which case you should probably just use a *different* repeat loop. Perhaps one that only runs limited number of times per frame, or waits for a certain milliseconds count so it doesn't run for longer than the length of a frame. You cannot use a repeat loop like this, because it stops stage events from occuring. yes, thats the idea, i found running this particular script outside a frame event running quicker. Yes, since if you use frame events you get one loop iteration per frame. If you want it to run faster then make it run batches, like run a loop 100 times per frame, or increase the framerate. now, how do i stop it? if needed... As I said before, you can't (that's the short answer anyway). While the loop is running, nothing else can be running, and no events will be processed. Therefore, any outside state such as the global variable you are using will be ignored because they are not updated until the loop is finished. The only thing that does keep running is system events such as the timer, so you can check the number of milleseconds elapsed and use that to stop the loop early. This is useful in a technique called timeslicing. Say the movie runs at 60 frames per second, you only have 1/60 seconds of time per frame. Call that 1/100 and you get 10ms available to your loop. If the loop runs for more than 10ms, you stop it and wait until the next frame, where it can start again. i.e.: if( stillRunning ) then startTime = the milliseconds repeat while true if( the milliseconds - startTime 10 ) then exit repeat -- do stuff end repeat end if This allows the loop to run safely alongside everything else director is trying to do, instead of completely hogging the CPU until the loop is finished. i've tested some updatestage during loop in order to animate a progress bar, the bar is updated, so i guess the movie doesn't completly stop as you describe... The reason for that is that the updateStage event basically stops the loop, does the remaining frame processing and then returns to the loop. During the updateStage call your loop is no longer running. However, if you do this, all it means is that you are running one loop iteration per frame, but forcing the maximum possible framerate. You might as well use exitFrame, and set an extremely high tempo (like 999). Since you will never acheive that framerate, you will get whatever is the most number of frames that can possibly be drawn in the time given. The advantage of doing things that way is that it's a bit more stable than constantly calling updateStage, which was not designed to be used that way, and may cause unpredictable behaviour in the rest of your movie. brings me to an idea will now try updatestage to pass the global stop value might work thanks anyway for the reply. Yes, it might work, I'm not 100% sure since I never use updateStage, so I can't say exactly how it behaves. However, I think what happens is that the event queue will be processed when updateStage is called, so it should work. However, as I and others have pointed out, it is inadvisable to call updateStage continually like this. There are better ways to do the same thing. - Robert [To remove yourself from this list, or to change to digest mode, go to http://www.penworks.com/lingo-l.cgi To post messages to the list,
Re: lingo-l How to stop a loop.
- Original Message - From: Fabrice Closier [EMAIL PROTECTED] got a script than stays looping in a repeat. in some case, the loop takes several seconds to end. But i want to be able to let him stop during the repeat. tried something like this via a button, but its ignored. ... You cannot use a repeat loop like this, because it stops stage events from occuring. In fact, it completely halts your movie. You need to use exitFrame to create the loop like this: property running on exitFrame me if( running ) then -- do stuff end if end -- Example usage on mouseUp me running = not running end This will do something once per frame, without affecting anything else in the movie. - Robert [To remove yourself from this list, or to change to digest mode, go to http://www.penworks.com/lingo-l.cgi To post messages to the list, email [EMAIL PROTECTED] (Problems, email [EMAIL PROTECTED]). Lingo-L is for learning and helping with programming Lingo. Thanks!]
Re: lingo-l How to stop a loop.
yes but i'am using a moviescript.. i just call an handler. the frame script is just on exitframe go to the frame end You cannot use a repeat loop like this, because it stops stage events from occuring. yes, thats the idea, i found running this particular script outside a frame event running quicker. now, how do i stop it? if needed... i've tested some updatestage during loop in order to animate a progress bar, the bar is updated, so i guess the movie doesn't completly stop as you describe... brings me to an idea will now try updatestage to pass the global stop value might work thanks anyway for the reply. Fabrice Robert Tweed heeft op donderdag 19 september 2002 om 14:24 het volgende geschreven: - Original Message - From: Fabrice Closier [EMAIL PROTECTED] got a script than stays looping in a repeat. in some case, the loop takes several seconds to end. But i want to be able to let him stop during the repeat. tried something like this via a button, but its ignored. ... You cannot use a repeat loop like this, because it stops stage events from occuring. In fact, it completely halts your movie. You need to use exitFrame to create the loop like this: property running on exitFrame me if( running ) then -- do stuff end if end -- Example usage on mouseUp me running = not running end This will do something once per frame, without affecting anything else in the movie. - Robert [To remove yourself from this list, or to change to digest mode, go to http://www.penworks.com/lingo-l.cgi To post messages to the list, email [EMAIL PROTECTED] (Problems, email [EMAIL PROTECTED]). Lingo-L is for learning and helping with programming Lingo. Thanks!] [To remove yourself from this list, or to change to digest mode, go to http://www.penworks.com/lingo-l.cgi To post messages to the list, email [EMAIL PROTECTED] (Problems, email [EMAIL PROTECTED]). Lingo-L is for learning and helping with programming Lingo. Thanks!]
Re: lingo-l How to stop a loop.
repeat with x = 1 to Myvar if the mouseDown then exit repeat else -- do your stuff end if end repeat -A. hi all, got a script than stays looping in a repeat. in some case, the loop takes several seconds to end. But i want to be able to let him stop during the repeat. tried something like this via a button, but its ignored. global stop on somehandler repeat with x = 1 to Myvar if Stop = true Stop = false exit repeat else do your job end repeat end on a button got a stop = true, global stop the thing doens't work. what should i need to use? the apple/. stops the loop but quits the app as well. Fabrice [To remove yourself from this list, or to change to digest mode, go to http://www.penworks.com/lingo-l.cgi To post messages to the list, email [EMAIL PROTECTED] (Problems, email [EMAIL PROTECTED]). Lingo-L is for learning and helping with programming Lingo. Thanks!] [To remove yourself from this list, or to change to digest mode, go to http://www.penworks.com/lingo-l.cgi To post messages to the list, email [EMAIL PROTECTED] (Problems, email [EMAIL PROTECTED]). Lingo-L is for learning and helping with programming Lingo. Thanks!]
Re: lingo-l How to stop a loop.
You cannot use a repeat loop like this, because it stops stage events from occuring. yes, thats the idea, i found running this particular script outside a frame event running quicker. now, how do i stop it? if needed... i've tested some updatestage during loop in order to animate a progress bar, the bar is updated, so i guess the movie doesn't completly stop as you describe... It's not so good practice to do updateStage inside a repeat loop, because you are slowing down the repeat a lot. I suspect that the amount of slowing down depends on the size of the stage that needs to be redrawn. You could do an updateStage every 100th repeat or so. -A. [To remove yourself from this list, or to change to digest mode, go to http://www.penworks.com/lingo-l.cgi To post messages to the list, email [EMAIL PROTECTED] (Problems, email [EMAIL PROTECTED]). Lingo-L is for learning and helping with programming Lingo. Thanks!]
Re: lingo-l How to stop a loop.
hi all, got a script than stays looping in a repeat. in some case, the loop takes several seconds to end. But i want to be able to let him stop during the repeat. tried something like this via a button, but its ignored. global stop on somehandler repeat with x = 1 to Myvar if Stop = true Stop = false exit repeat else do your job end repeat end on a button got a stop = true, global stop The repeat loop is hogging the CPU. If you're using a keyDown handler, it will wait until the repeat finishes. I would either change the repeat loop to a frame event, or use on keyPressed. keyPressed will interrupt a loop. Cordially, Kerry Thompson [To remove yourself from this list, or to change to digest mode, go to http://www.penworks.com/lingo-l.cgi To post messages to the list, email [EMAIL PROTECTED] (Problems, email [EMAIL PROTECTED]). Lingo-L is for learning and helping with programming Lingo. Thanks!]
Re: lingo-l How to stop a loop.
Thanks! guess if keypressed asciinum can also work... then.. great!! just what i need! about the update stage, i agree with you, but since the loop is opening files and checks the content, i only update the stage when a new file is opened. the progress is size bar/howmuch file x filenumber. it doesn't really slows down in this particular case. Fabrice Andreas Gaunitz P11 heeft op donderdag 19 september 2002 om 15:39 het volgende geschreven: You cannot use a repeat loop like this, because it stops stage events from occuring. yes, thats the idea, i found running this particular script outside a frame event running quicker. now, how do i stop it? if needed... i've tested some updatestage during loop in order to animate a progress bar, the bar is updated, so i guess the movie doesn't completly stop as you describe... It's not so good practice to do updateStage inside a repeat loop, because you are slowing down the repeat a lot. I suspect that the amount of slowing down depends on the size of the stage that needs to be redrawn. You could do an updateStage every 100th repeat or so. -A. [To remove yourself from this list, or to change to digest mode, go to http://www.penworks.com/lingo-l.cgi To post messages to the list, email [EMAIL PROTECTED] (Problems, email [EMAIL PROTECTED]). Lingo-L is for learning and helping with programming Lingo. Thanks!] [To remove yourself from this list, or to change to digest mode, go to http://www.penworks.com/lingo-l.cgi To post messages to the list, email [EMAIL PROTECTED] (Problems, email [EMAIL PROTECTED]). Lingo-L is for learning and helping with programming Lingo. Thanks!]
Re: lingo-l How to stop a loop.
- Original Message - From: Fabrice Closier [EMAIL PROTECTED] yes but i'am using a moviescript.. i just call an handler. the frame script is just on exitframe go to the frame end You could use timers, or create an object to put in the actorList, or add it to exitFrame in your frame script. Just use an if statement so it only runs when you need it. It's easy to avoid the repeat loop, it's simply a question of whether or not you actually need the repeat loop to do something many times per frame, in which case you should probably just use a *different* repeat loop. Perhaps one that only runs limited number of times per frame, or waits for a certain milliseconds count so it doesn't run for longer than the length of a frame. You cannot use a repeat loop like this, because it stops stage events from occuring. yes, thats the idea, i found running this particular script outside a frame event running quicker. Yes, since if you use frame events you get one loop iteration per frame. If you want it to run faster then make it run batches, like run a loop 100 times per frame, or increase the framerate. now, how do i stop it? if needed... As I said before, you can't (that's the short answer anyway). While the loop is running, nothing else can be running, and no events will be processed. Therefore, any outside state such as the global variable you are using will be ignored because they are not updated until the loop is finished. The only thing that does keep running is system events such as the timer, so you can check the number of milleseconds elapsed and use that to stop the loop early. This is useful in a technique called timeslicing. Say the movie runs at 60 frames per second, you only have 1/60 seconds of time per frame. Call that 1/100 and you get 10ms available to your loop. If the loop runs for more than 10ms, you stop it and wait until the next frame, where it can start again. i.e.: if( stillRunning ) then startTime = the milliseconds repeat while true if( the milliseconds - startTime 10 ) then exit repeat -- do stuff end repeat end if This allows the loop to run safely alongside everything else director is trying to do, instead of completely hogging the CPU until the loop is finished. i've tested some updatestage during loop in order to animate a progress bar, the bar is updated, so i guess the movie doesn't completly stop as you describe... The reason for that is that the updateStage event basically stops the loop, does the remaining frame processing and then returns to the loop. During the updateStage call your loop is no longer running. However, if you do this, all it means is that you are running one loop iteration per frame, but forcing the maximum possible framerate. You might as well use exitFrame, and set an extremely high tempo (like 999). Since you will never acheive that framerate, you will get whatever is the most number of frames that can possibly be drawn in the time given. The advantage of doing things that way is that it's a bit more stable than constantly calling updateStage, which was not designed to be used that way, and may cause unpredictable behaviour in the rest of your movie. brings me to an idea will now try updatestage to pass the global stop value might work thanks anyway for the reply. Yes, it might work, I'm not 100% sure since I never use updateStage, so I can't say exactly how it behaves. However, I think what happens is that the event queue will be processed when updateStage is called, so it should work. However, as I and others have pointed out, it is inadvisable to call updateStage continually like this. There are better ways to do the same thing. - Robert [To remove yourself from this list, or to change to digest mode, go to http://www.penworks.com/lingo-l.cgi To post messages to the list, email [EMAIL PROTECTED] (Problems, email [EMAIL PROTECTED]). Lingo-L is for learning and helping with programming Lingo. Thanks!]