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

Reference Utility for Programmatically Comparing (Diffing) VIs

Code and Documents

Attachment

Overview


When developing a large application, it sometimes becomes necessary to compare (or 'Diff') several VIs at once, during a code iteration or review, for example. In this case, it may not be ideal to open each pair of VIs to be compared using the Compare VIs option in LabVIEW. The attached utility demonstrates how a user can programmatically compare their VIs. Simply call this utility inside a loop, passing it the paths of the VIs that the user wishes to compare. The VI will return whether or not there was a difference along with a textual description of what was different, which is very useful if a report with the differences is necessary. The attached VI (vi_diff.vi) uses the CMP Compare two VIs.vi, which is located in \project\procmphier.llb. Please note that the attached VI uses the LabVIEW 8.0 directory so if you have a later version of LabVIEW, please update the location of the CMP Compare two VIs.vi to your LabVIEW directory.

**The accompanying code represents a very specific use case for NI products. For more general examples, please refer to ni.com/examples, the LabVIEW Example Finder, or the NI driver help files that come with every NI driver.

Inputs

Path of VI 1: The path for the first VI you want to compare.

Path of VI 2: The path for the second VI you want to compare.

VI Attributes: Compares attributes of the two VIs using the settings in the VI Properties dialog box.

Front Panel: Compares objects on the front panel.

Front Panel Position/Size Changes: Compares the position and size of the objects on the front panel.

Block Diagram: Compares the functional differences on the block diagrams.

Block Diagram Cosmetic Changes: Compares changes on the block diagrams that do not affect the execution of the VI, such as color changes, visible subdiagrams in Case and Stacked Sequence structures, format and precision of constants, and Event structures.

Block Diagram Position/Size Changes: Compares the position and size of the objects on the block diagram.

Outputs

Same?: Boolean indicator indicating whether or not a difference was found between the two VIs.

Differences: A string indicator with descriptive information about what the difference between the two VIs was.

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

Comments
ejones
Member
Member
on

In your Overview,  could you elaborate on any dependences or licenses this example may need?  

Contributors