Dieser Inhalt liegt nicht in Ihrer bevorzugten Sprache vor.

Der Inhalt wird Ihnen in einer anderen verfügbaren Sprache angezeigt. Ihr Browser bietet ggf. Funktionen, die Sie bei der Übersetzung des Textes unterstützen.

Set the Default Value of a Control in a VI Programmatically

Updated Jun 27, 2023

Environment

Software

  • LabVIEW

This article will guide you step-by-step through the process of writing some information into a control or indicator and setting it as the default value programmatically via VI reference.

You will need to open a reference to your target VI from another VI. Then you need to use Property Nodes to open a reference to the target VI’s Front Panel and subsequently, the Controls/Indicators on the Front Panel.

Open your main VI and follow these steps:
  1. Open a reference to the target VI by passing the target VI’s path to the Open VI Reference VI.
  2. Create a new VI Class Property Node that opens a reference to the front panel.
  3. Wire the front panel reference into a new Property Node and use this node to open an array of references to the controls/indicators on the front panel.
  1. Wire the array of references to a for loop.
  2. You use this for loop to index the controls/indicators on the target VI and case them based on their individual labels.
  3. Since the value of a control/indicator takes a variant type, use a To More Specific Class VI to specify what type the control/indicator you would like to write to actually is (e.g., integer, string, waveform).
  4. In the case for the control/indicator you would like to write to, you can use a Property Node to write to the Value property of the specified control/indicator.
  5. Make the value you just wrote the default value by passing the target VI’s reference through a Default Value: Make Current Value Default Invoke Node.
  6. Save the target VI by passing the target VI’s reference through a Save Instrument Invoke Node
  1. Close reference and catch any errors.


Additional Information

  • Note: This method can't be used to set the default values within the same VI. This is because the Invoke Method: Default Values: Make Current Default is not settable when the VI is running.
  • Note: Save Instrument Invoke Node is not available with the Runtime Engine (i.e., if you run this VI as an executable or a .dll on a system that does not have the development environment installed). This is documented in the LabVIEW help.