Thanks Mike,
- I set console.abortEnabled true, but when when StarAlignment.executeOn() returns I find abortEnabled has been reset to false. It appears I may need to set it to back to true again after each process execution. Is this expected behavior?
Yes. This happens because the core application disables the console pause/abort function when it runs a process instance. The process has to enable pause/abort explicitly when/if appropriate, and the core will disable it again when the process terminates execution. This is standard behavior, and has been implemented this way because not all processes can be interrupted arbitrarily and/or asynchronously. In PixInsight, a process always starts knowing that the platform is in a 'secure' state where the user cannot interrupt it.
So if you call ProcessInstance.executeGlobal() or ProcessInstance.executeOn() from a script, you have to assign true to console.abortEnabled after the call if you want to let the user pause and/or abort your script afterwards.
- Is there a way to tell if a process execution itself has aborted? Maybe executeOn() will throw (I am not sure). Or maybe there is a process property (So far I can't find one).
You cannot know if a process has been aborted by the user. However, ProcessInstance.executeOn() returns true if the process has been executed successfully, false otherwise. If the process has been aborted, the return value is false. There cannot be exceptions thrown from a module, so ProcessInstance.executeXXX() cannot throw exceptions.
I have some important improvements to the JavaScript runtime planned for PI 1.8, including more and more precise control on process execution and, among many other things, the possibility to call module-defined methods for process instances, beyond executeOn() and executeGlobal().