LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Load / Save control's properties automatically

Hi,

 

For thouse who pay attention to the small details in the GUI here I'm sharing a way to load on start up the last used values of the controls (when the previous time the program was closed). The idea is that one complex VI may have many controls that will require the user interaction for setting their initial values. When LabView was closed all current control values are lost and during the next startup of the VI they have to be set again. In some cases this might be very painful and time consuming process.

 

An array of strings is used to define:

- which of the controls will be updated

- what is the default value if there is no INI file (this is the first start of the program ever)

 

The subVI are taking care to detect the type of the control and convert the string into the appropriate type. You can check how the VI works in the following way:

1. Run the VI - if no INI was found default values will be loaded

2. Change the settings of the controls

3. Press STOP button - this will save the current control values to INI file

4. Close LabView, Open LabView and run the VI again - you'll find out that last values will pop up on the screen

 

Let me know if you find something that might be changed or improved. Thank you.

 

Version - LabView 2014

0 Kudos
Message 1 of 6
(3,875 Views)

If you would like to see some robust and mature solutions which can do the same and even more, check out these free toolkits, they are very useful! I specially like the MGI functions where you can save Graph (curve colours, etc) and other front panel settings (you can download these for free via VIPM):

 

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

Hi Blokk,

 

I was not aware of this solution - it looks really good! Thank you very much for the suggestion!

 

One question - how you specify which controls values to be loaded in case the INI file is missing or corrupted?

 

Best regards,

Luben 

0 Kudos
Message 3 of 6
(3,859 Views)

@Luben.hristov wrote:

Hi Blokk,

 

I was not aware of this solution - it looks really good! Thank you very much for the suggestion!

 

One question - how you specify which controls values to be loaded in case the INI file is missing or corrupted?

 

Best regards,

Luben 


The mentioned toolkits just use the default values I think if the file is missing, or not acting at all.

Another question is the so called "mutation", when you change for example an existing cluster (typdef as should be always), like adding new elements. OpenG handles this case well, read more explanation from @Sam_Sharp:

 

http://forums.ni.com/t5/LabVIEW/Saving-application-state-for-later-resume/m-p/3225945/highlight/true...

0 Kudos
Message 4 of 6
(3,854 Views)

Hi Blokk,

 

I loaded the toolkit as you suggested and it works really well but I was not able to find how to specify the update only of specific controls without modifying the MGI VIs (it's not a good idea to update all controls but only the ones we really need). Also some controls like the Graphs may have multiple values for updating (like different cursor's positions, scales, etc.) so MGI is not an universal solution but a good starting point.

 

Thank you for the useful hint!

0 Kudos
Message 5 of 6
(3,839 Views)

Hi,

 

The latest update of the code - cluster structure optimized.

0 Kudos
Message 6 of 6
(3,807 Views)