Example Code

Saving Enum Controls to XML

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 is an example of how to save the value of enum controls on the front panel to a .xml file and subsequently restoring them.

 

 

Description

This example shows how to save enum controls to an xml file and then reads the same xml file to restore the data. There are two VIs: Saving and Restoring.

 

The Saving VI first gets the name and value of the enum control using property nodes and then saves them as two values in a cluster. This cluster is then converted into xml format and written to a text file for readability.

 

The Restore VI then reads the xml file and converts it back into a cluster of two elements. We then read the two elements to restore the data into the enum.

 

This is just an example of one method of saving controls with an xml file. Instead of using xml you can use the OpenG library or the configuration VIs included with LabVIEW.

 

 

 

Steps to Implement or Execute Code

  1. Download the appropriate .zip files for your installation of LabVIEW
  2. Run the Saving Enum to XML (LabVIEW 20xx).vi first and follow the instructions on the front panel
  3. Run the Restoring XML to Enum (LabVIEW 20xx).vi second and follow the instructions on the front panel

 

 

Requirements

Software

LabVIEW 2012, 2011, 2010

 

Hardware

None

Gabriel M.
Product Marketing Engineer - Academic Courseware
National Instruments

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