-
-
July 20, 2021 at 5:49 amAndyJPSubscriber
Is there a command like Wscript.Quit for stopping a script execution; if some condition was found during execution?
September 9, 2021 at 7:17 amsawltrodSubscriberHi, did you find any solution?
September 10, 2021 at 12:41 amAndyJPSubscriberNo. Ansys just ignores quaestions about scripting, or gives pointless links to their incomplete manual... with mistakes in references. Last time they told me to look in the "HFSS Scripting Guide", which has totally no functions which I asked about... I found some useful functions in the "Electronics Desktop Scripting Guide". So I think, the support does not know much about scripting themselves, and throws you any random stick with "scripting" written on it. Only on time they reacted more or less cautiously, when I was having serious system crashes, which is probably dangerous for their MIL customers... but that appeared to be the problem of Microsoft VBS core, so they do not care anymore...
Obviously, they don't care that the stop signal is ignored by the scripting engine.
Oh, OK. Since it is not a compiled, and very lightly syntax-checked language, you can use any function that results in the interpreter error (the same Wscript.Quit) inside the conditional check.
September 10, 2021 at 6:59 pmjdmacSubscriberAt the risk of sounding like one of those internet denizens who, instead of answering your question, tells you to re-think your whole way of working, I would suggest that you avoid hard aborts in your code. You'd probably be better off having logic that pops back up the stack and cleanly exits the main routine if an exit condition is met.
In IronPython, you can just call sys.exit() to immediately force quit your script, but this will raise a tacky error message in EM Suite. (It will also leave the COM object scope blocked if you don't call Shutdown() before your hard exit.) I suppose if you don't mind the error message saying your script crashed, then sys.exit() would be fine.
In Vbs, this is easier, as you can use a GoTo statement to jump directly to the end of your subroutine. Of course, if you're nested 12 layers deep in the stack (sub within sub within function within function...) then that's not going to work very well. If that's the case, then you're right back to needing nicely nested logic that pops you back up to Main().
September 13, 2021 at 12:59 amAndyJPSubscriber>At the risk of sounding like
Sorry, but you do.
>You'd probably be better off having logic that pops back
Obviously that's what conditional exit does. A command in procedural VBS script simply CAN NOT interrupt the execution asynchronously, until the full computation is done.
But whenever you see the computation goes the wrong way, you HAVE to stop it. But HFSS script CAN NOT be stopped by simply signalling neither Clean Stop, nor ABORT.
The only way is to raise a flag, either on the filesystem, or in the HFSS itself using a postprocessing VAR.
September 13, 2021 at 1:03 amAndyJPSubscriber>In IronPython, you can just call sys.exit() to immediately force quit your script
That's because it is Iron Python, and not the main script engine of HFSS. Yes, maybe it works in IP... but it requires learning the already extinct and ABANDONED language, which would not be used anywhere else, and which interacts with external procedure calls for commanding HFSS. In what part is it better than making external calls in MATLAB or Octave?
Besides that, in principle I refuse dealing with any language where the accidental whitespace may affect the program flow. And I am not alone in this believe.
>In Vbs, this is easier, as you can use a GoTo statement
That's a good point. A good old forgotten technique... occasionally causing unrecoverable process errors. But it realy should not leak beyond the interpreter space, which is cleared every time you stop the script.
Viewing 5 reply threads- The topic ‘Stopping a script from the script itself, the right way?’ is closed to new replies.
Ansys Innovation SpaceTrending discussions- HFSS Incident Plane Wave excitement mode
- Simulation of capacitor combining eddy currents with displacement currents
- How to calculate eddy and hysteresis losses of the core?
- Ansys Maxwell 3D – eddy current
- How to determine initial position in motion setup
- dq graph non-conformity
- Simplorer+Maxwell Cosimulation results and Maxwell results mismatch
- Parametrizing coil “terminals” with coil geometry
- On-chip inductor design
- Maxwell circuit – PWM
Top Contributors-
1421
-
599
-
591
-
565
-
366
Top Rated Tags© 2025 Copyright ANSYS, Inc. All rights reserved.
Ansys does not support the usage of unauthorized Ansys software. Please visit www.ansys.com to obtain an official distribution.
-