LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to make sure that the value of a control (such as double) initializes to the last value when the VI was closed?

Solved!
Go to solution

I am using a cluster as a control. I would like the double values in that control to automoatically populate to their last set values when the VI is opened or accessed for the first time. It would be great if someone could point that out to me. Thanks in advance!

0 Kudos
Message 1 of 8
(2,808 Views)

Here's a relatively simple and extensible example.


___________________
Try to take over the world!
Message 2 of 8
(2,801 Views)

There are many ways to do this.  The most common way is to use the configuration VIs in the File palette. 

 

You can always just do Edit>Make Current Values Default and then save the VI.  Of course that will only work in Development mode.  If you want to do this for an executable you have to use the configuration VIs and write to an INI file or save to XML, etc.

LabVIEW Pro Dev & Measurement Studio Pro (VS Pro) 2019 - Unfortunately now moving back to C#, .NET, Python due to forced change to subscription model by NI. 8^{
0 Kudos
Message 3 of 8
(2,795 Views)

 


@tst wrote:

Here's a relatively simple and extensible example.


Thanks tst.  I looked but couldn't find that thread.

 

LabVIEW Pro Dev & Measurement Studio Pro (VS Pro) 2019 - Unfortunately now moving back to C#, .NET, Python due to forced change to subscription model by NI. 8^{
0 Kudos
Message 4 of 8
(2,792 Views)

The link worked for me when I just tried it. I contains an interesting dicussion regard methods for saving the settings of front panel controls, although some of it may be a bit dated as it was from 2007 and some of the concerns regarding the OpenG tools mentioned have been addressed, at least up to LabVIEW v8.6, I haven't tried them for v2009 or v2010. They work very nicely (the OpenG tools) and handle a variety of controls that my previously self developed solution didn't handle well, like typedefs and arrays. The tools will take a reference to a cluster control and either create or read back an ini type file.

Putnam
Certified LabVIEW Developer

Senior Test Engineer North Shore Technology, Inc.
Currently using LV 2012-LabVIEW 2018, RT8.5


LabVIEW Champion



0 Kudos
Message 5 of 8
(2,768 Views)
Solution
Accepted by topic author neophyte_ab

In my opinion, configuration files are the easiest and best method.  Just save your last values to the file when your code ends.  At the beginning of your code, read the file and populate the controls with the values read.  With config files, the section name can be the cluster name, and the key names can be the control names.

 

I know OpenG has some pretty nice VIs to do this, but I would rather use NI native functions when I can.  When porting to a new system, there is no need to copy any extra library of VIs (OpenG library).  The native VIs come with Labview.

- tbob

Inventor of the WORM Global
0 Kudos
Message 6 of 8
(2,749 Views)

Thanks much! That was very helpful.

0 Kudos
Message 7 of 8
(2,730 Views)

 


@tbob wrote:

In my opinion, configuration files are the easiest and best method.


 

Easiest? Maybe, if you only need to do this for one control. I contend that I could probably recreate my saving and loading VI from scratch (without any OpenG code) and get it to work for N controls faster than you (or at least I) can write code which will save and load 2 or 3 controls.

 

Best? Certainly not. Once you have the VI, it's scalable up to N controls and M VIs even if you don't use the OpenG VIs internally. The OpenG VIs simply allow easy access to the values through an ASCII editor, but the VI works fine without them.


___________________
Try to take over the world!
0 Kudos
Message 8 of 8
(2,714 Views)