LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Get Control Default

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.

 

0 Kudos
Message 1 of 14
(5,664 Views)

When in LV the scripting option is enabled ( Options -> VI Server - > Scripting ) then there is a propery node that does this

 

Floris Reinders
Senior Project Engineer / CLA
0 Kudos
Message 2 of 14
(5,644 Views)

Looks like it requires scripting to access.  I would imagine it would still work in an executable though.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 3 of 14
(5,628 Views)

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?

0 Kudos
Message 4 of 14
(5,599 Views)

P.S. Thank you for trying.

0 Kudos
Message 5 of 14
(5,596 Views)

@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.

Message 6 of 14
(5,578 Views)
I always use a one text file that i insert it into project
any time that my software start piece of my algorithm check inside the text for find default value and then I use local variable for this part of my code
0 Kudos
Message 7 of 14
(5,566 Views)

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):

  1. Use the VI Method "Get All Control Values" (remember to wire T to Controls to get the Controls, otherwise you get Indicators).
  2. Use the VI Method "Reinitialize All Controls to Default".
  3. Use the Value Property to read the Default Value of "Default 5" and save as "Default Valule (5)".
  4. 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.
  5. Use the Value Property to read the saved Value of "Default 5" and save as "Saved 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 ...)

 

Get Default Value.png

Bob Schor

0 Kudos
Message 8 of 14
(5,533 Views)

@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):

  1. Use the VI Method "Get All Control Values" (remember to wire T to Controls to get the Controls, otherwise you get Indicators).
  2. Use the VI Method "Reinitialize All Controls to Default".
  3. Use the Value Property to read the Default Value of "Default 5" and save as "Default Valule (5)".
  4. 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.
  5. 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.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 9 of 14
(5,513 Views)

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

0 Kudos
Message 10 of 14
(5,504 Views)