From 9:00 AM - 12:00 PM CDT on Saturday, June 6th, will be undergoing system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

Reusing Snippets of Code

LabVIEW 2018 Help

Edition Date: March 2018
Part Number: 371361R-01
View Product Info

DOWNLOAD (Windows Only)

LabVIEW 2016 Help
LabVIEW 2017 Help
LabVIEW 2018 Help
LabVIEW 2019 Help
LabVIEW 2020 Help

You can save snippets of code, or a VI snippet, from the block diagram to reuse later or to share with other LabVIEW users. LabVIEW embeds the code into a .png image file. The image shows a picture of your code and contains the actual code you specify.

Complete the following steps to reuse a snippet of code from the block diagram.

  1. Select a section of code on the block diagram.
Note Note  Do not select a section of code that contains an unsaved subVI. If you include a subVI in the section of code, you first must save the subVI on disk.
  1. Select Edit»Create VI Snippet from Selection.
  2. In the dialog box that appears, select or browse to the directory where you want to save the VI snippet.
  3. Click the OK button.
  4. (Windows and macOS) (Optional) Drag the .png file from the directory where you saved it and drop it onto the block diagram. LabVIEW drops the actual code that is in the file and automatically wires controls and indicators to wires in the section of code that have loose ends.
  5. (Optional) Share the .png file with other LabVIEW users in one of the following ways.
    • Attach the file to any Web document such as an email. (Windows and macOS) Other users can download the file and then drag and drop the file onto the block diagram to use the code.
    • Embed the image in an HTML page such as a message forum. (Windows and macOS) Other users can drag the image onto the block diagram to use the code.
Note Note  (Linux) You can save and share VI snippets to show images of code, but you cannot drag and drop VI snippets onto the block diagram to use the code.

LabVIEW does not embed subVIs in the .png file. Any subVIs called in the VI snippet must be present on the computer when a user drops the .png file onto the block diagram. Otherwise, the VI snippet contains broken code.

When you open a VI snippet .png file with image editing software, LabVIEW displays the version of LabVIEW in which the VI snippet was saved in the upper right-hand corner of the image. To use the code of a VI snippet, the version of LabVIEW you are running must be the same as or later than the version of LabVIEW in which the VI snippet was saved.

Note Note  If you save a VI snippet .png file with the image editing software, that software might remove the code from the .png file. If you then add the .png file to the block diagram, only the image appears on the block diagram, not the code. To avoid losing the code, do not save the .png file with the image editing software.


Not Helpful