PDA

View Full Version : How to break a endless loop??


em3
03-28-2009, 07:24 PM
Hi, I have a script that is looping and wont let me access anything in max. How can I stop it?

JHN
03-28-2009, 07:39 PM
Several things can be the case, can you post the part of the script that is looping?

-Johan

Blacksmith3D
03-28-2009, 07:43 PM
you can use the exit command to break a loop. For example...

local iterations = 0;
local maxIterations = 1000;
while (true) do
(
-- do stuff here...

if (iterations > maxIterations) then
exit
iterations = iterations + 1
)

in MAXscript, 'exit' is the same as 'break' in c/c++

I hope this helps!

ZeBoxx2
03-28-2009, 08:51 PM
also.. anytime you're still testing code that involves long / heavy loops, add this inside the loop...

if (keyboard.escPressed) do ( throw "ESCAPE PRESSED" )


That will respond to an Escape Key press much better than the built-in esc key handler which often doesn't respond at all if the loop does heavy processing.

em3
03-28-2009, 08:59 PM
ah!

I killed the 3dsmax task and restored the backup.

CODE=INSERTED!

Thanks guys!

Mr-BlueSummers
03-28-2009, 10:08 PM
Neat trick, thanks ZeBoxx.

Gravey
03-29-2009, 12:33 AM
Nice trick Richard, <copy> <paste>
thanks

thatoneguy
03-29-2009, 04:29 AM
Sticky it!

:D

CGTalk Moderation
03-29-2009, 04:29 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.