LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Global - set default values during runtime

Hello,

 

Is there a way to reinitialize a global variable to default values during runtime?

I know how to do it by passing the vi reference during developpement but with the exe, there is no more vi:)

 

Best regards

0 Kudos
Message 1 of 5
(3,868 Views)

Hi Tapitapo,

 

welcome to the forum!

 

Instead of using a method "Reinit to default" you could just write a (default) value to your global variable.

But then you are open for RaceConditions, when there is more than one place where the global is written to…

 

Why not replace the global by a FGV/FunctionalGlobalVariable aka AE/ActionEngine?

 

Why do you think there is no global VI in your exe? It should still be there, but just inside your EXE!

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 2 of 5
(3,857 Views)

Hello, thank you for the reply

 

- In case the global is modified, using a constant to initialize the global will force me to modify the vi, the "reinit to default" method no, minimum effort is better for me:)

 

- I use a global because it let me to be way more flexible during sql access. Only one AE will made my code a cable forest and is less modifiable, from my sight.

 

- The native code is embedded in the .exe after compilation of course, but there is no more vi as it is source, it is not possible to reference to the global.vi.

0 Kudos
Message 3 of 5
(3,845 Views)

Hi Tapitapo,

 

I use a global because it let me to be way more flexible during sql access. Only one AE will made my code a cable forest and is less modifiable, from my sight.

There will be no "cable forest": you have an AE VI/icon where you have the global variable icon right now. The same amount of wires…

 

In case the global is modified, using a constant to initialize the global will force me to modify the vi, the "reinit to default" method no, minimum effort is better for meSmiley Happy

It is just one more state of the AE. It is a one-time effort to incorporate that state in the AE.

It is even less effort to call the AE to execute that state when compared to calling the method with getting the needed reference !

 

The native code is embedded in the .exe after compilation of course, but there is no more vi as it is source, it is not possible to reference to the global.vi.

The "native code" is embedded in the VI: each VI is compiled while you edit it!

And you still have all the VIs in the executable…

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 4 of 5
(3,836 Views)

You can look into config files for saving/initializing variables from an executable.

0 Kudos
Message 5 of 5
(3,781 Views)