Initialize Array Control With Modifiable Values After VI Is Run

Updated Aug 21, 2023

Environment

Software

  • LabVIEW

Other



 

  • How to Initialize and edit an array control with default values upon each run of a VI?
  • How do I default the array to enable the amount of elements that I need?

There are several ways to accomplish this. Each method requires you to set default values and to initialize the array control to default values when the VI is run.
 

Set Default Values: 

Option 1: Manually type in default values

  1. Type in values to which you would like to initialize your array control into the control on the front panel.
  2. Left-click on the outer border of the array control, ensuring that the dashed blue selector box encompasses the entire array control.
  3. Right-click and select Data Operations»Make Current Value Default.

Option 2: Use the Initialize Array function to auto-populate your array with default values.

  1. Add an Initialize Array function to the block diagram.
  2. Create constants for the array dimensions and value.
  3. Create an array indicator on the output. Run the VI.
  4. Right-click the array indicator and select Data Operations » Make Current Value Default.
  5. Right-click the array indicator and select Change to Control.

Reinitialize to Default Values:

  • You can re-initialize the array control to default values manually by right-clicking the array control before running the VI and selecting Data Operations»Reinitialize to Default Value.
  • To do this programmatically, right-click the array control on the block diagram and select Create»Invoke Node»Reinitialize to default.

Put the initialized array control in a while loop to allow the user to edit it. To ensure the array control is initialized immediately when the VI is run, wire the error wire into the while loop to enforce data flow. The below code allows the user to edit an initialized array and write those values to a text file.