How to terminate script execution from within DazScript?
shoei321
Posts: 113
Simple question - I need to be able to terminate execution of my script under certain conditions, for example :
if (unrecoverableErrorCondition) {
exit();
}
But I exit() doesn't do it, nor does System.exit(), return, or any of the usual candidates. I don't see anything under DzScriptContext or DzSystem for this either. How is this best done?
Thanks
Comments
I don't know. continue would terminate any loop you were in, then you could have some kind of check to make sure execution of instructions ended -
continue and break just skip or exit the current looping structure. I'm looking to end script execution all together.
In Java this would be System.exit(), in PHP and Perl exit(), in Python sys.exit(), etc. I can't seem to find the equivalent in DazScript, nor does it seem to be in the ECMAScript spec.
I was suggesting using continue to get out of the loop you are in, if any, and then using a boolean flag to make sure that nothing else is done - so the script should then just run do-nothing function calls until it gets to its end. Or put error checks around the actual code - I often end up with so many nested if ( we-have-the-thing-we-need) statements that in a print the actual working code would be on the right margin.
Wrap your code in a function and exit the function early...
-Rob