Example Code

Bailing Out of an Infinite Loop (LabVIEW)

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

Download All

Overview

The example shows a very simple infinite loop. Once you have run the code, you will be relentlessly prompted by a dialog box. Within 50 ms of closing the dialog box, you will be greeted by another! This leaves no time to manually click the stop button or the abort button.

 

Description

Of course, the best way to get out of infinite loops is to avoid coding scenarios which allow then to occur. However, it only takes a short lapse in developer concentration to accidentally write and run an infinite loop. To get around this issue, you can hold ctrl + . (full stop), while you click the OK button. This is the LabVIEW shortcut for “abort”. Of course, hitting abort is not a graceful method of stopping a VI... but, it is a little less “brute force” than forcing LabVIEW to close via task manager (the method I used to use before learning this technique). The following piccie illustrates an amusing infinite loop scenario!! (this image is with gratitude to the wonderful, sharp, brilliant nerds at XKCD web comics)

 

Requirements

  • LabVIEW 2012 (or compatible)

 

Steps to Implement or Execute Code

  1. Run the VI.
  2. A dialog prompted and click OK button cannot abort it.
  3. Hold ctrl while you click the OK button to stop it.

 

Additional Information or References 

VI Snippet

155.png

 

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

Rich Roberts
Senior Marketing Engineer, National Instruments
Connect on LinkedIn: https://www.linkedin.com/in/richard-roberts-4176a27b/

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

Comments
Josh_E
NI Employee (retired)
on

Ahhhh, so that's how I was meant to do it all along!

Josh E
Applications Engineer
National Instruments UK & Ireland