View Full Version : End endless for loop
10-18-2005, 01:07 AM
So I've accidentally created a endless for loop/print statement and I can't seem to figure out how to stop it. Normally I'd just create a listen statement or just press esc... Any suggestions?
10-18-2005, 06:23 AM
Post the code. Hard to help without seeing it.
10-18-2005, 08:02 AM
nothing in peticular... just a for loop within a for loop. and if I havn't done it right, they keep printing out... over and over and over... ect...
Meaning, the output I created will loop for a long time before completeing because of bad codeing on my part. The problem is, the only way I've found to stop it, is to force quit maya.
10-18-2005, 03:08 PM
Again, without seeing it it's hard to pinpoint your problem. However, you need a condition in your loop to test if something is true or not to break out of the loop. Just step through it in your head and try to follow the logic.
10-18-2005, 03:51 PM
I don't think he's asking for help on figuring out the source of the infinite loop. Rather he's asking if there's a way to interrupt an infinite loop in Maya. I can't say that I know of any off the top of my head, other than to quit Maya forcefully (eg. end the process).
10-18-2005, 04:20 PM
Bryan Ewert has a script to do just this. I have never tested it, but try this link out.
10-18-2005, 06:32 PM
What keliun said. I'm not trying to fix the script. I'm trying to figure out how to terminate it, if it get's stuck in an endless loop.
Thanks mohavland... I'll give that a shot. Though it would have been nicer if maya built in something like... the use of the escape key
10-18-2005, 09:43 PM
I think I'm in an endless loop :banghead:.
Why would you program in the possiblity of an endless loop but then want user intervention to terminate it? Makes no sense. If "this happens", terminate loop, "else" continue to loop.
10-19-2005, 03:08 AM
I wouldn't program in an endless loop. I would happen on accident while I'm writing code for something. Sometimes I write a bad for() loop and maya gets stuck looping on itself. In that case I would want a way of killing the script without having to end the maya task. I want a way out if I mess up while writing my code. For instnace, I was making a mirror cluster weights script yesterday, and maya was listing out all the verticies for me. Well I had accidentally mess up the script and it was printing all the verticies for every x value for every vertex on the object I was working on. That's 4000 verts times 4000 xvalues times 4000 verts.
Now, I don't want to wait for maya to print out that many. And it certianly wasn't my intention, but due to sloppy codeing on my part, that is what I had to deal with. So because of this, I want a way to cancel for loops until I'm better at writing code
10-19-2005, 04:00 AM
Sorry, but that is the totally wrong way of learning to code. Putting in code to help with sloppy coding is sure fire for disaster.
10-19-2005, 05:11 AM
If you have suggestions on how to write code perfectly the first time, I would love to hear it. However please do not critize me for doing things my self taught way. Thank you
10-19-2005, 05:37 AM
Sorry, no offense intended. Having wirtten C++, VB and perl scripts and programs, I've never written apps perfect the first time around for sure.
One thing you could add to your code is a condition test like this
for($i=0; $i < $hugeNumber;$i++)
if($i == 64000000)
This will break out of the loop if your counter gets too high.
This is a bit old but is the only thing I know that will do what you want. I've emailed this guy ahile back and was nice enough to send the source code before. You could do the same but would need to be re-compiled to the version of Maya your using. It did come handy when running a batch file and I needed to escape out of it.
If you run into an endless loop situation and you need help with stepping through I'd love to help.
10-19-2005, 05:37 AM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.
vBulletin v3.0.5, Copyright ©2000-2014, Jelsoft Enterprises Ltd.