How Can I Initialize an Array Control with Values as Soon as a VI is Run and Allow the User to Edit Values?

Updated Dec 21, 2017

Reported In

Software

  • LabVIEW Full

Other

Primary Software: LabVIEW Development Systems>>LabVIEW Full Development System 2015

 

Issue Details

How to Initialise and edit an array control with default values upon each run of a VI

Solution

There are several ways to accomplish this. Each method requires two things: 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. A snippet is included below that allows the user to edit an initialized array and write those values to a text file. This is one simple way out of many possibilities to accomplish the task.

WAS THIS ARTICLE HELPFUL?

Not Helpful