LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Initializing control values

Hi everyone,
I'm building an application that calls several subVIs when the user makes different actions. The subVI X, when called, opens in a new window and is made of several numeric controls. It appears that, even if I've setted defaut values (Operate­­>>Make Current Values Defaut), the subVI will always open with the values of the previous execution. For my application, it's just an esthetic question, but I am wondering if there was a way to always get the same defaut values when the subVI is called. I could do it with a property node (value property) for each control but maybe there is an other way, weightless due to the big number of controls my subVI has... Thanks a lot, I appreciate.

Phil
0 Kudos
Message 1 of 5
(3,073 Views)
Hi Phil,

This can be done by using local variables (better than property nodes in your case due to memory management), but again it'll be a lot of trouble to create all the local variables. Another way is to create a file that saves your default values for all controls and load it at the beginning of your subVI.

First you can create such file by using a VI reference to your subVI. Use "Get All Control Values" invoke node, flatten the output to strings and save to a file.

Then at the beginning of the subVI, you can read that file, unflatten the string back to cluster format, open a VI reference to your subVI, then use invoke node "Set Control Value" to initialize them to the values saved in the file.

This algorithm is independent of how many controls y
ou have, and it should suit your need well.

Hope this helps,
Dan
Message 2 of 5
(3,073 Views)

A set of VIs doing exactly what Dan recommends can be found at the end of this post:

http://exchange.ni.com/servlet/ProcessRequest?RHIVEID=101&RNAME=ViewQuestion&HOID=5065000000080000001F250000&ECategory=LabVIEW.LabVIEW+General

This is a pretty long-and-winding post, but is worth reading (has good discussion on type descriptors and variants, etc.). Anyways, the last post (by Bmarsh on 7/18/2001) has the VIs. Config' file VIs are used to implement this.

Regards,

Khalid

0 Kudos
Message 3 of 5
(3,073 Views)
Hi Phil,

You can write the control values to an external configuration file and read them back from the configuration file at the beginning of the vi execution. More information on this can be found in the following tutorial. http://zone.ni.com/devzone/conceptd.nsf/webmain/1C98B128C80E52BE8625692E0055D456?opendocument

Regards,
Ankita A.
Applications Engineer
National Instruments
0 Kudos
Message 4 of 5
(3,073 Views)
Hi Phil
If I understand your question try this...

In the block diagram of the subVI that you want to start with default values;

1) From the Functions menu >> Application Control >> Invoke Node

2) Right click the node >> Select Class >> VI Server >> VI

3) Left click to select a Method from the drop down list. From this list you will find:

(i) Reinit all to default
(ii) Make current values default

If you place this node at the beginning of your execution structure it should do the job in (i) above. You could then use (ii) before the subVI completes execution to set new defaults.

I have attached a plain example to illustrate.

Hope this helps and happy programming.

Kenos
0 Kudos
Message 5 of 5
(3,073 Views)