Programmatically Reset Control Values of VI

Updated Jun 19, 2018

Reported In

Software

  • LabVIEW Full
  • LabVIEW Base
  • LabVIEW Professional

Programming Language

  • LabVIEW G

Issue Details

Sometimes the values on the front panel of a VI carry over from previous runs. Is there a way to programmatically reset all the values of all controls on my front panel?

Solution

If you are using LabVIEW version 8.0 or later, there is a method of the VI class Default Values.Reinitialize All to Default. This method is identical to the menu option Edit>>Reinitialize All Values to Default. To call this method programmatically, follow the steps outlined below:
 

  1. Select the block diagram window
  2. Bring up quick drop (Press CTRL + SPACE)
  3. Type ‘VI Sever Reference’ and double click the top result
  4. Place the ‘This VI’ box on the block diagram by left clicking
  5. Hover over the right hand side until the wiring tool appears
  6. Right click and select ‘Create -> Method for VI Class -> Default Values -> Reinitialize default Values’​
  7. Wire the output of the ‘VI Sever Reference’to the top left input of the invoke method
 




In versions of LabVIEW prior to 8.0 you will need to use the Control class method Control.Reinitialize To Default to set the default value of each front panel control individually. To implement this follow the below steps for each control:
 

  1. Select the block diagram window
  2. Bring up quick drop (Press CTRL + SPACE)
  3. Type ‘VI Sever Reference’ and double click the top resul
  4. Place the ‘This VI’ box on the block diagram by left clicking
  5. Hover over the right hand side until the wiring tool appears
  6. Right click and select ‘Create -> Property for VI Class -> Front Panel’
     

  1. Right click the Panel output of the newly created property node and select ‘Create -> Property for Panel Class -> Control[]’


  1. Bring up quick drop (Press CTRL + SPACE)
  2. Type ‘For Loop’ and double click the top result
  3. Place the For loop down by clicking and dragging
  4. Bring up quick drop (Press CTRL + SPACE)
  5. Type ‘Invoke Node’ and double click the top result
  6. Place the invoke node in the for loop
  7. Wire together these elements following the image below​
  1. Click on the method in your invoke node and select 'Reinitialize to Default'
     

WAS THIS ARTICLE HELPFUL?

Not Helpful