Notifications
Clear all

[Closed] Clear all variables? Also… Break?

Couple of newb questions:

Is there a script operation to reset all global variables? I would like to be able to check and make sure my code isn’t depending on any variables that I might have manually entered while debugging without rebooting max every half hour or so.

Also sometimes I’ll accidentally enter in some bad code for instance:

while i < 1 do
(
i -= 1
)

that’s another time when I have to just close and reopen max. I would like to be able to type in Stop or something to that effect and just kill whatever operation is running even if it returns a “error expected” or something like that in my listener.

6 Replies

have you tried the escape key? what it does it interrupt the current maxscript operation. You should see interupted in your listener when you press it. actually now that i’ve read your post again, i’m not sure that’s what your after.
There may be another way to reset globals but if you initialise them to undefined before your script starts, that would effectively do it.

The problem with clearing global variables is it doesn’t also clear rollouts, some functions etc.

Thanks. Escape key is what I was after. I’ll have to try it next time I get that problem.

It’s when I’m entering scripts in the listener and then eventually run a bit of bad script or something and it stops accept new variables and what not.

Swami posted a script to script spot once eons ago ( circa 5 years ago??? ) that cleaned out all global variables by brute force. it was ugly but it did the job. Otherwise… there is no built in method to clear out global variables.

With more than 5 digits wouldn’t that take like 2.5 years?

a 9 symbol string name with alpha+numeric lettering plus _ and ” ” would be 36 symbols

9 ^ 36 = ~2.25e+34

Even at 1000 combinations per second it would run for the better part of a week.

Edit:

Ok I found that script and took a look. It seems what it does is load all of the maxscripts in a defined directory. Analyzes the maxscript for variables which are either created or expected and then clears only those. Definitely something which can be done in a lifetime. : ) Except I’m still not certain how you’re supposed to define a custom scripts folder for the macro. Perhaps tommorow when I’m a wee bit less bleary eyed and ready to roll I’ll be able to read the code properly.

Where could i find that script?

scriptspot search for “clear”