Example Code

Return a Value in an Array that was Clicked on with a Mouse.

Products and Environment

This section reflects the products and operating system used to create the example.

To download NI software, including the products shown below, visit ni.com/downloads.

    Software

  • LabVIEW

Code and Documents

Attachment

Overview

This example demonstrates determining which element of an array was clicked and returning that value.

 

Description

An event structure is used to detect a mouse click. Using the control reference provided by the event structure, there are two methods to extract the value of the element clicked for the generic array. The first method uses the To More Specific Class function. You will need to provide the Target Class constant to match the data type of the array. This will produce the proper reference to provide to a property node for the value. The second method uses the Variant to Data function to convert the value into the proper data type. For the Boolean array, the value change can be detected with the Event Structure. The changed value and the index of the changed element is determined by comparing the previous and current arrays.

 

Requirements

  • LabVIEW 2012 (or compatible)

 

Steps to Implement or Execute Code

  1. Create an Event Structure to detect the Mouse Down and Boolean Array Value Change events
  2. Use a property node to extract the Array Element property
  3. Create a case structure to handle the 2 approaches to extracting the value from a generic array
  4. For the Boolean array, compare the old and new arrays to extract the value changed and the index of the changed value.

 

Additional Information or References

 

Front Panel

1.PNG

 

Block Diagram

2.PNG

 

3.PNG

 

4.PNG

 

**This document has been updated to meet the current required format for the NI Code Exchange.**

Scott G.
AE Specialist
National Instruments

Example code from the Example Code Exchange in the NI Community is licensed with the MIT license.