VI Scripting

From LabVIEW Wiki
(Redirected from VI scripting)
Jump to: navigation, search
VI Scripting Nodes appear as Light Cyan

VI Scripting, also known as Scripting, deals with the ability of LabVIEW to use G to write G. VI Scripting contains several new VI Server classes, properties, methods, and events so you can create, move, and wire objects; edit the connector pane; create new VIs; and more. Scripting is useful for generating or editing VIs automatically based on simpler configurations. Examples of scripting include the code generated by Express VIs, the code generated for LVOOP Accessor VIs and the code generated by the NI Vision Builder. Because scripting requires recompiling the VI and may break it, you can not run scripting code on a VI which is reserved for running.

History

VI Scripting began shipping with LabVIEW beginning with LabVIEW 2010. However, it is available for download from the LabVIEW Tools Network for LabVIEW 8.6 and 2009. Before LabVIEW 8.6 scripting was an undocumented feature and was available to those that knew how to enable it as early as LabVIEW 5.0 through flags in the LabVIEW configuration file. However, as it was not documented or supported to the greater community, it had the potential to be dangerous. Before scripting was official an NI employee famously refferred to it as something akin to Rusty Nails.

Usage

VI Scripting generally falls into three categories:

  1. Using G to automate the generation of more G
  2. Using G to create add-on tools (i.e. Quick Drop, Shortcut Menu Plugins, etc.)
  3. Using G to inspect G (i.e. VI Analyzer)

VI Scripting uses properties and methods to create, locate, and operate on Block Diagram objects (i.e. primatives, structures, wires, and terminals), Front Panel objects (i.e. controls, indicators, decorations, splitters, panes, and panels), edit the Connector Pane and the VI.

Code Generation

Many of the main application frameworks use VI Scripting to automate the generation of code, modules, messages, etc. Some examples of this include:

General Guideline for Code Generation: VI Scripting code can get large and complex very quickly. A guideline to VI Scripting is to start with a template, make a copy, and then edit the copy.

Another common use case of VI Scripting is to automate repetitive tasks. For example, if the code required the generation of many similar VIs. It might be more efficient to create a template and then write the scripting code to copy, modify, and save the VI.

Creation of Add-on Tools

The creation of add-on tools can improve efficiency by automating repetitive tasks or making tasks easier to accomplish. There are many hooks into the LabVIEW IDE to let you create add-on tools.

Presentation to help create new tools:

Cool tools that currently exist:

  • More to come

Code Inspection

Another use of VI Scripting is to automate inspection of code to ensure adherence to style guidelines and effective programming practices, to catch common errors, and improve performance, functionality, and maintainability.

Such tools include:

  • VI Analyzer - The LabVIEW VI Analyzer Toolkit helps you improve the quality and readability of graphical code developed in LabVIEW software.
  • LabVIEW Unit Test Framework - The Unit Test Framework Toolkit provides interactive tools to create, configure, manage, and execute tests that check VIs for functional correctness.
  • JKI VI Tester - software test framework for LabVIEW that allows software developers to test their LabVIEW code; VI Tester is based on the industry standard xUnit software test architecture that is used in many other programming languages
  • JKI Caraya Unit Tester - open source assertion and unit testing framework for LabVIEW; convert your manual test VIs you use for debugging into unit test cases with nearly no effort

Enabling VI Scripting

Instructions for enabling VI Scripting

Getting Started

Tips and Tricks

Exploring the Depths of the VI Server - by Quentin Alldredge, Q Software Innovations

This presentation goes into the depths of the VI Server including Basic LabVIEW, VI Scripting, and even the Private stuff, showing many of the Properties, Methods, and Events I have found useful in the creation of LabVIEW IDE add-ons.

5 Steps to Become a VI Scripting Ninja - Fabiola De la Cueva, Delacor

Why would you want to use LabVIEW Scripting? LabVIEW VI scripting allows LabVIEW Developers to programmatically generate, edit, and inspect LabVIEW code. You would want to use LabVIEW VI Scripting to create tools that would make you and your team more efficient, to enforce coding guidelines or to automate repetitive tasks.

See Also