02-12-2016 05:02 PM
I was looking to compare a control value to it's default value. I did not find a method or property that would Get / Read the default value. Frustrating, the VIs have it in their file somewhere. Anyone know of an elegent way to do it?
Attached work around uses Reinit.All, and restores origional values. I would not want to do many controls.
I'm now using a hard coded constant in an FGV. Empty path gets the FGV value, and path inputs get compared to it.
02-12-2016 05:48 PM
When in LV the scripting option is enabled ( Options -> VI Server - > Scripting ) then there is a propery node that does this
02-12-2016 06:05 PM - edited 02-12-2016 06:06 PM
Looks like it requires scripting to access. I would imagine it would still work in an executable though.
02-12-2016 11:40 PM
Using scripting for this task is like hanging a picutre with a sledge hammer. Not elegant:
1. All PCs running this code would need scripting enabled.
2. Not supported for executables?
02-12-2016 11:43 PM
P.S. Thank you for trying.
02-12-2016 11:56 PM
@Pappion wrote:Using scripting for this task is like hanging a picutre with a sledge hammer. Not elegant:
1. All PCs running this code would need scripting enabled.
2. Not supported for executables?
Why is this not elegant? What do you expect that would make it "elegant"?
1. I don't think all PC's need scripting enabled. Just the one that initially creates your VI. You can still open VI's with scripting nodes on other PC's that don't have scripting enabled. You just need to have scripting enabled on which PC/LabVIEW environment that is going to lay down the property node originally. Opening that same VI on a non-scripting enabled computer is not going to cause the property node to disappear.
2. Looking at the help for the defval property node, it looks like it is available in the run-time engine, thus it should work in an .exe.
02-13-2016 12:16 AM
02-13-2016 06:18 AM
Here's how to do it (and a little Demo that shows it works). The Snippet uses a control, "Default 5", whose default value is 5, shown by wiring a Constant (which "becomes" 5) to a Value Property, and which is then reset to the non-default value (for this control) of 0. To get the default value of this control (5) while retaining its value (0):
When you run this, Default Value (5) will contain 5, and Saved Value (0) will contain 0. This is coded in LabVIEW 2015, but should work in most earlier versions (I think LabVIEW 7 had these properties ...)
Bob Schor
02-13-2016 07:21 AM - edited 02-13-2016 07:22 AM
@Bob_Schor wrote:Here's how to do it (and a little Demo that shows it works). The Snippet uses a control, "Default 5", whose default value is 5, shown by wiring a Constant (which "becomes" 5) to a Value Property, and which is then reset to the non-default value (for this control) of 0. To get the default value of this control (5) while retaining its value (0):
- Use the VI Method "Get All Control Values" (remember to wire T to Controls to get the Controls, otherwise you get Indicators).
- Use the VI Method "Reinitialize All Controls to Default".
- Use the Value Property to read the Default Value of "Default 5" and save as "Default Valule (5)".
- In a For Loop, unbundle the Array of Clusters from Step 2 and using the VI Method "Set Control Value", reset each Control to its saved value.
- Use the Value Property to read the saved Value of "Default 5" and save as "Saved Value (0)".
Major overkill. There is an invoke method at the control level so you only need to reinitialize that one control.
02-13-2016 07:24 AM
I thought there was such a method, but when I looked for it, I didn't find it ... I agree that it is otherwise "major overkill" ...
BS