Abort script nicely

Solved1.03K viewsScripting
0

Hi,

In my script, I check the user input, and in case I find something wrong, I want to inform the user (using “Alert()” to send a custom message) and then quit the script nicely. I did not find anything other than “assert 1==0”, but this gives another annyoing pop-up to the user. Using “System.exit(0)” exits the script, but closes Quantrix as well, which is not the idea.

Any ideas?

Thanks, Gilbert

gilles Selected answer as best November 29, 2022
0

Sorry Lyndsey,

return DOES work IF you use it correctly!!!

Return does not abort the script, but just the exits the current code bloc, NOT the entire script, as an unfamiliar user like me might expect. Also, you can not return from “each” – what I tried.

So I do just set a boolean “ErrorFlag” to true, get out of the current block, and testing ErrorFlag before entering the next one … and return there again. In my case of the “each” is not time-critical, I do finish the each, but just do not execute more inside code (putting it into a “if (!ErrorFlag)”).

So yes, return works, if done correctly :-).

Thanks for your help, Lyndsey!

gilles Edited answer December 11, 2022
You are viewing 1 out of 3 answers, click here to view all answers.

Latest Questions