Example Code

Create and Write to New File When Button is Pressed

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

Coding that exemplifies how to start writing to a file at the press of a button.

 

Description

This examples shows how you can use a case structure to start writing to a new file at the press of a button.

We are using a "First Call?" VI to make sure that we create a new file on the first iteration. On subsequent iterations we will go to the "False" case by default, and go back to the "True" case when the button is depressed. The "True" case of the case structure creates a new file path based of the current system time, and passes that file name around the While Loop using a Shift Register. The "False" case uses the file path from the previous iteration, and writes new data to the file.

 

Requirements

LabVIEW 2012 (or compatible)

 

Steps to Implement or Execute Code
1. Select the Run button.
2. Move the switch to record.
3. Stop the VI with the Stop Button.
4. Check on the same path as the VI a .xlsx file.


Additional Information or References

 Snippet.png

Justin Parker
National Instruments
Product Support Engineer

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