01-28-2016 07:00 PM
Is it expected behavior that I lose global variables when registering or deregistering user commands?
It appears ScriptCmdReset is called somewhere in the Registering functions... Is there any way to avoid it?
I want to register a user command so I can respond to the OnLoaded event in the navigator, but If I register it, and lose all my global variables, that doesn't work...
01-29-2016 02:52 AM
Hi RussellSenior,
no, the expected behavior is that adding or registering user commands does not perform a reset.
Removing user commands an the other hand has to initiate a reset.
The actual reset is delayed and can only be executed when DIAdem is idle.
DIAdem is idle if all scripts are finished and no dialog is open.
01-29-2016 08:03 AM
Got it. That explains a lot. Can I force a reset before my scripts are done. Like maybe use Pause?
I was planning to remove the user command when the script was done, but the rest of the scripts rely on global vars. So, I will just avoid removing any user commands.
Thanks.
01-29-2016 08:35 AM
Hi RussellSenior,
no, the reset can't be forced for technical reasons.
Every running script engine (scripts, SUDs) gets a pointer to the script engine with global commands and variables (thats what makes them global).
Since these script engines can have references or a call stack with jumps to this engine, a reset can only work if all running scripts and SUDs are finished.
So removing unused commands and variables works only at the end of a script and is executed after the script is finished.
I hope that explained it.
DIAdemo
01-29-2016 08:37 AM
I have to say, I'm really happy with the support I get on this forum. Answers are always easy to come by on a wide array of topics. Thank you so much for the quick explanation!