How Do I Programmatically Determine the Different Files Referenced in a Project?

Updated Nov 29, 2023

Environment

Software

  • LabVIEW Application Builder Module
  • LabVIEW

As of now I have to physically look at the types of files and their names in a project file to determine what type of file they are, and their name.  I would like to do this programmatically such that I can make a list of the builds present in a project according to my input criteria.

Yes, it is possible to programmatically look at all builds present within a project. As shown in the figure below, you would use a set of invoke and property nodes to open the project, get all the descendents of type "EXE" (application builds), and create an array of with their names.


To recreate this VI, follow the steps listed below:
 

  1. Place an invoke node on the block diagram. This invoke node is found in the functions palette by going to Programming»Application Control»Invoke Node. Right-click the invoke node and select Methods»Project»Open. This will load the LabVIEW project. 
  2. Right-click the path input and Create»Control. Place a second invoke node on the blockdiagram and connect the Project Open output to the reference input of this second invoke node. Right-click the invoke node and select Method»Open Window. This will display the Project Explorer Window. You can then select the appropriate path to the project.
  3. Place a property node on the block diagram, which is found by going to Programming»Application Control»Property Node in the functions palette. Connect the reference and error outputs of the second invoke node to the reference and error inputs of the property node.
  4. Right-click the property node and select Properties»Root. This returns a reference to the project root in the Project Explorer Window.
  5. Place a third invoke node on the block diagram. Connect the Root output of the property node to the reference input of the third invoke node. Right-click the invoke node and selectMethods»Get All Descendents. This returns project items that are descendants of the referenced item.
  6. Right-click the Type input terminal and select Create»constant. Type EXE as the string constant. Place a For Loop after the third invoke node and add a second property node inside the loop. Connect the output of Get All Descendents to the reference input of the second property node. Right-click the property node and select Properties»Children which returns an array of references to all children of the referenced project item.
  7. Expand the property node to allow for a second property.  Right-click this property and select Properties»Name. This gets the name of the references project item.
  8. With autoindexing enabled, wire the output of the Name property to an indicator that is outside of the For Loop. This indicator will show the Build Names within the specified project.
  9. Connect the error wires as shown in the following block diagram
 

 
If you do not specify EXE, LabVIEW returns all project descendents (builds, VIs, libraries, etc...). The help for the Get All Descendents method lists other possible types that you can specify besides EXE that might be useful, such as VI, DLL, source distribution, and installer.

Note:  After you find the names of builds present in a project, you might want to build those build specifications. To do this in LabVIEW 2011 or later, use the Build VI. In LabVIEW 2010 or earlier (refer to build VI in LabVIEW help), use the BuildTargetBuildSpecification VI located in the ​labview\vi.lib\AppBuilder directory.