ni.com is currently undergoing scheduled maintenance.

Some services may be unavailable at this time. Please contact us for help or try again later.

DIAdem

cancel
Showing results for 
Search instead for 
Did you mean: 

ScriptCmdRemove Resets GlobalVars

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...

 

 

0 Kudos
Message 1 of 5
(4,398 Views)

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.

 

 

 

 

 

 

0 Kudos
Message 2 of 5
(4,381 Views)

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. 

0 Kudos
Message 3 of 5
(4,372 Views)

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

 

Message 4 of 5
(4,368 Views)

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! 

0 Kudos
Message 5 of 5
(4,366 Views)