05-20-2013 07:39 AM
I am using sample code from Labview to save propery settings for a couple of controls (config.llb) and I want to know how to upload these settings when the main VI just open but is not running, similar to C# Properties.Settings.Default.Save();
Thanks
05-20-2013 08:14 AM
Right click the control and select Data Operations>>Make Current Value Default, then save the VI. You can also do this for all the controls and indicators on the FP through the edit menu.
05-20-2013 11:23 AM
Hi tst,
Thanks for your comments, however, lets me explain what I am trying to do:
As I mentioned above I have saved current control settings using Labview sample code: write configuration settings file.vi
but instead of using "read configuration settings file.vi," I wonder if there is a way to upload these settings when main VI just opens but not executing yet (in executable mode).
05-20-2013 12:16 PM
Just to clarify about my last comment: I wonder if there is a way to upload these settings when main VI is just loaded into memory, similar to C# as explained in this link: http://msdn.microsoft.com/en-us/library/bb397755.aspx
05-20-2013 12:18 PM
frn wrote:
but instead of using "read configuration settings file.vi," I wonder if there is a way to upload these settings when main VI just opens but not executing yet (in executable mode).
No - your code can't do anything until it starts running, and that includes changing values. In an executable, there is no (easy) way to change the default values. Normally you would set your program to run automatically when it loads, which would then load your configuration, and if you need to allow the user to change settings before it runs, then you would include some sort of Run button in your code instead of using the default LabVIEW one. You would also hide the toolbar so the run arrow isn't even visible.
05-20-2013 12:48 PM
Thanks nathand,
Based on your information, I could let main VI to run automatically so that settings are loaded into controls then stop it immediately upon completion. Add a local variable as a counter, so everytime the user run the VI subsequently it will not repeat loading the previuos step, until the vi is closed and re-open it again (I need to try!).
Because of this behavior I am planning to save control settings everytime the vi complets executing (as the last step). Is there a way to save this control settings automatically when a user closes the application (the "X")?
In other words, run the "Save Current Control Settings.vi" automatically when the user closes the application?
05-20-2013 01:47 PM
You should never stop your application - the user should never have to push LabVIEW's Run button (again, it shouldn't even be visible to the user). You should structure your code to handle any such needs yourself. You can handle events such as the close (X) button on a window using an Event structure.
05-21-2013 03:30 AM - edited 05-21-2013 03:31 AM
Like Nathan said, you should definitely not require users to stop and run VIs directly. You should alsways do that yourself. If you want to save and load control values, you need code which does this. You can see an example of such code at https://decibel.ni.com/content/docs/DOC-15349 but there are also many others.
05-21-2013 03:35 AM
@frn wrote:
Thanks @nathand,
Based on your information, I could let main VI to run automatically so that settings are loaded into controls then stop it immediately upon completion. Add a local variable as a counter, so everytime the user run the VI subsequently it will not repeat loading the previuos step, until the vi is closed and re-open it again (I need to try!).
Because of this behavior I am planning to save control settings everytime the vi complets executing (as the last step). Is there a way to save this control settings automatically when a user closes the application (the "X")?
In other words, run the "Save Current Control Settings.vi" automatically when the user closes the application?
The event structure can capture the Front panel close ("X") and save your settings as it closes.
If you group the front panel as a cluster it's extremely easy to use Read/Write XML to load and save all front panel values on start and exit.
/Y
05-21-2013 11:24 AM
Yamaeda wrote:
"If you group the front panel as a cluster it's extremely easy to use Read/Write XML to load and save all front panel values on start and exit."
On above comment "on start," do yu mean when VI is uploaded to memory? or VI needs to run to get front panel updated (same as C# does with Properties.Settings.Default.Save())
According to nathand: "No - your code can't do anything until it starts running, and that includes changing values. In an executable, there is no (easy) way to change the default values."
Again, what I am trying to do is to update a couple of controls values in executable mode by using the event structure (as you suggested) to capture the Front panel close ("X") and save the settings as it closes. Then update control settings as VI is loaded into memory, but does not need to run to update values. Again same behaivor as C#: http://msdn.microsoft.com/en-us/library/bb397755.aspx