From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

Example Code

Using buttons as menu items

Code and Documents

Attachment

Overview

This example demonstrates an easy and effective way to use boolean buttons as menu items. (producer - consumer loop)

Description

Many LabVIEW application has some kind of a menu bar at the top which controls the application (changing a tab on a tab control, sending messages from one loop to another etc.). I also have seen many overly convoluted solutions as many developers tend to handle the buttons individually. That is fine if you have 2-3 buttons, but complicates the code a lot and in many cases the scalabilty of the application start to decrease.

The example I have attached demonstrates how to use the producer consumer architecture processing all the buttons within one case of an event structure with high scalablilty, maintainability and readibility.

Note: I wanted to keep this example one-vi-only. Its highly recommended to make some elements of the code a typedef if you reuse this example. Also the block diagram can be made smaller by creating subVIs.


Steps to Implement or Execute Code

  1. Download the code
  2. Launch in LabVIEW

Requirements

Software

LabVIEW 13.0

Hardware

None

Additional Images or Video

menu_items.gif

menu_items_code.gif

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

Contributors