Example Code

Compare Version Strings

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 a simple VI that facilitates comparing two version strings of the format "n.n.n.n" to tell whether the two versions are equal, or which one is later than the other. 

 
Description
This VI is used to compare version strings of the type "n.n.n.n" to tell if one string represents an earlier or later version than the other.  For version strings, each "n" is interpreted as an integer.  This function interprets each integer, so that version 1.11 is recognized as greater than version 1.2, for example.  Note that missing minor versions are interpreted as 0, so that verion 1.1.0 is equal to version 1.1.  Also note that this VI is only designed to work with version integers of up to four digits.  E.g. it can parse version 1.9999.1.0 correctly, but is not guaranteed to parse version 1.10001.1.0 correctly.  In addition, this VI ignores insignificant formatting issues, such as extra spaces or leading zeros in any of the sub-versions.

Original Code by David Thomson February, 2015

copyright 2015,  Original Code Consulting

This VI is available as freeware for use by the LabVIEW community, with the sole condition being that the attribution to the author be left intact in this documentation.

  

Requirements

Software:

  1. LabVIEW 2013 (or compatible)


Steps to Implement or Execute Code

  1. Supplying two version strings as inputs
  2. Run the application

 

Additional Information or References

VI Snippet

 Compare Version Strings 2013 NIVerified.png

 

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

-------------------------------------------------------------
David Thomson Original Code Consulting
www.originalcode.com
National Instruments Alliance Program Member
Certified LabVIEW Architect
Certified Embedded Systems Developer
-------------------------------------------------------------
There are 10 kinds of people: those who understand binary, and those who don't.

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