LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Reinitialize some values at start, not all

Solved!
Go to solution

I'm making a program to take some measurements and I'm using a lot of controls/indicators. I want to reinitialize most of the values to default at the start of the program and at the end. I have 3 values that a user enters before the program starts and I need to retain those values for later on in the program, I can't reinitialize them. Is there a simple way to do this? I can't use the "Reinitialize All To Default". Currently I have all the values, except for the 3 user inputs, set to default at the start of the program by using local variables at the start of the program. But this looks messy and I don't want to do the same thing at the end of the code.

0 Kudos
Message 1 of 10
(3,159 Views)

There is nothing wrong with using locals to reinitialize values as long as you are careful about race conditions. 

 

Otherwise, you could use property nodes, but that is generally frowned upon.  You could bundle the references of all of the controls that you want to initialize, then convert the cluster to an array, then use a FOR loop to re-initialize them.  I would recommend toggling "Defer panel updates" to reduce the performanc hit.  The advantage of this method is that you can encapsulate all of this in a subvi.

 

 

>

"There is a God shaped vacuum in the heart of every man which cannot be filled by any created thing, but only by God, the Creator, made known through Jesus." - Blaise Pascal
Message 2 of 10
(3,154 Views)
Solution
Accepted by topic author ashifulk

Or you could use something like this:

reinitialise.png


CLA CTAChampionI'm attending the GLA Summit!
Subscribe to the Test Automation user group: UK Test Automation Group
Message 3 of 10
(3,148 Views)

I'm still new to LabVIEW so I'm having a little trobule understanding the "DigNum (strict)" property node... Is that restricting the numbers in the VI from being set to their default value? When I run your code it doesn't work, I keeping getting an error that says "LabVIEW:  VI Reference is invalid."

0 Kudos
Message 4 of 10
(3,134 Views)

Thats because the snippet tools strip the reference. Try the attached vi.


CLA CTAChampionI'm attending the GLA Summit!
Subscribe to the Test Automation user group: UK Test Automation Group
0 Kudos
Message 5 of 10
(3,127 Views)

Thank you. I like this idea. I created a simple program based on the shift register concept and attached is the VI. This works from me just testing it out but do you see any problems with using this?

0 Kudos
Message 6 of 10
(3,120 Views)

Sorry, I am using Labview 2011 so cannot open youe code!


CLA CTAChampionI'm attending the GLA Summit!
Subscribe to the Test Automation user group: UK Test Automation Group
0 Kudos
Message 7 of 10
(3,118 Views)

Attached is a screenshot of the code... It's pretty simple, so I don't think the VI is needed.

0 Kudos
Message 8 of 10
(3,114 Views)

There is a separate reinit method for each control, so I would suggest something like the following (2011), which resets all controls except the ones in the array.

 

Of course, if you only want to reset a few controls, you build their references into an array and call the reinit method on them.


___________________
Try to take over the world!
Message 9 of 10
(3,100 Views)

@tst wrote:

There is a separate reinit method for each control, so I would suggest something like the following (2011), which resets all controls except the ones in the array.

 

Of course, if you only want to reset a few controls, you build their references into an array and call the reinit method on them.


You gave me new learning today. So Kudos!

-----

The best solution is the one you find it by yourself
0 Kudos
Message 10 of 10
(3,093 Views)