01-17-2013 08:12 AM
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.
Solved! Go to Solution.
01-17-2013 08:31 AM
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.
01-17-2013 08:35 AM
Or you could use something like this:
01-17-2013 08:58 AM
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."
01-17-2013 09:13 AM
Thats because the snippet tools strip the reference. Try the attached vi.
01-17-2013 09:29 AM
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?
01-17-2013 09:31 AM
Sorry, I am using Labview 2011 so cannot open youe code!
01-17-2013 09:33 AM - edited 01-17-2013 09:33 AM
Attached is a screenshot of the code... It's pretty simple, so I don't think the VI is needed.
01-17-2013 10:08 AM
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.
01-17-2013 10:25 AM - edited 01-17-2013 10:26 AM
@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!