From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

String globals keep resetting

Solved!
Go to solution

Hello,

 

I'm having a problem getting some string constants I have defined in a global variable file to stay saved in the file. I'm guessing I may be doing it incorrectly but I basically want these string variables to stay constant in the global file, right now I'm using a string control to define them. The problem with this is that these values get wiped everytime I close out Labview. I've attached my global VI.

 

Thanks,

 

Konrad

0 Kudos
Message 1 of 6
(2,666 Views)

If they clear you must have some function that writes to this file with empty values.

Attaching the Global doesn't help much, the main vi would be better. 🙂

/Y

G# - Award winning reference based OOP for LV, for free! - Qestit VIPM GitHub

Qestit Systems
Certified-LabVIEW-Developer
0 Kudos
Message 2 of 6
(2,662 Views)
Solution
Accepted by topic author niedk

Right click the global, select find all instances. Look through the find window and it should say if the different instances are read or write. Double click any that are "write" to see where they are being written to.

0 Kudos
Message 3 of 6
(2,651 Views)

The values in the global are only there until the global leaves memory.  This is true of all VIs, not just globals. If the values will never chnage, use Edit > Make Current Values Default on the Global 1.vi front panel.  Then save the VI.  If you need to change the values in yout main program, then you should write the data to a file before closing your program and read the data from the file as soon as the main program begins executing.

 

Lynn

Message 4 of 6
(2,647 Views)

There may be a better way to do this, but off the top of my head, you could scrap the global if it's really read only. Create a cluster with all your constants and put it in a lvlib. Set it to private. Create a public read accessor for it to be used throughout yoru code. I guess you could stil change them locally in this case once a copy was gotten from the function, but you couldn't write back to the actual global instance.

Message 5 of 6
(2,646 Views)

Lynn,

 

Thanks, this is what I was trying to do. I wanted to avoid extra definitions in my main vi itself.

 

Konrad

0 Kudos
Message 6 of 6
(2,643 Views)