Notifications
Clear all

[Closed] How to break a endless loop??

 em3

Hi, I have a script that is looping and wont let me access anything in max. How can I stop it?

7 Replies
 JHN

Several things can be the case, can you post the part of the script that is looping?

-Johan

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!

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

ah!

I killed the 3dsmax task and restored the backup.

CODE=INSERTED!

Thanks guys!

Neat trick, thanks ZeBoxx.

Nice trick Richard, <copy> <paste>
thanks

Sticky it!