Set Control Values by Index Function

Sets values to the controls for the VI you reference. This function offers better performance than VI Server objects that write to the terminal of a front panel control, such as using the Value property in the Control class. However, this function requires more advanced application design than other methods for setting control values.


icon

Inputs/Outputs

  • cvirn.png VI Refnum

    VI Refnum specifies a reference to the VI for which you want to set multiple control values. You can wire a strict or non-strict reference to this input. The default is a reference to the current VI.

  • c1di32.png control indexes

    control indexes specifies the indexes of the front panel controls for which you want to set values.

    Use the Control Index property in the Control class to retrieve control indexes.
  • c1dfxdt.png data values

    data values specifies the values to write to the controls. The default is a variant, but you also can specify the data type for the values you want to write to the control. To specify a single control, wire a scalar index to control indexes and wire a single value to data values.

  • cerrcodeclst.png error in (no error)

    error in describes error conditions that occur before this node runs. This input provides standard error in functionality.

  • ierrcodeclst.png error out

    error out contains error information. This output provides standard error out functionality.

  • The Set Control Values by Index function requires that the VI for which you want to set control values is running or in run mode. Furthermore, the controls for which you want to set values must have terminals on the block diagram.

    Note Because controls nested within clusters or arrays do not have terminals on the block diagram, you cannot set values for those controls.

    This function iterates over the length of the shorter of the two arrays you wire to control indexes and data values. The function attempts to set all values and does not stop on the first error. If an error occurs for multiple indices or values, LabVIEW reports only the first error.

    Application Design Considerations

    Use the following recommendations to obtain the best performance when you set control values with this function:

    • Retrieve the index of a control only once during an initialization section of an application.
    • To set control values for the current VI, leave VI Refnum unwired.
    • Set multiple values in a single call to minimize overhead.
    • To set values for a group of controls that have the same data type, wire an array of that data type to data values. For example, wire an array of 64-bit double-precision floating point numbers to data values to update a large group of numeric controls whose representation is 64-bit double-precision, floating point.