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.
LabVIEW VI Scripting is used to create Quick Drop shortcuts, augment right-click menus in LabVIEW, create custom VI Analyzer tests and other code automation tools (such as the productivity tools that ship with DQMH)
You can follow five easy steps to become a VI Scripting Ninja*:
- Enable/Install VI Scripting
- Become familiar with the VI Scripting help topic and shipping examples
- Join the Quick Drop Enthusiasts group
- Join the VI Analyzer Enthusiasts group
- Join the LabVIEW Shortcut Menu Plugins group
- (Bonus step) Check out other examples out there
Step 1: Enable/Install LabVIEW VI Scripting
For LabVIEW 8.6 and LabVIEW 2009, download and install LabVIEW Scripting.
For LabVIEW 2010 and later, enable VI Scripting via Tools>Options>VI Server>VI Scripting
As far as I know, VI scripting is still an unsupported feature. If you need help, the best place to go is the LabVIEW APIs Group and the LAVA VI Scripting group or any of the groups that we will be describing later.
Oh! And before you get too excited about writing LabVIEW VIs with LabVIEW, remember that the majority of VI Scripting methods do not run as part of an executable (Sorry!).
Step 2: Become familiar with the LabVIEW VI Scripting shipping examples
It also includes a series of exercises that guide you through the creation of some of the shipping examples. Depending on how you learn best, you can start with the help topic above and do the exercises one by one or skip directly to the shipping examples and investigate how they were put together and how they work. To find the VI Scripting examples, go to Help>Find Examples…>Programmatically controlling VIs>Editing and Inspecting VIs
The video below shows the following examples:
- Adding Objects
- Drop-Add Function Inside While Loop
- Using Traverse
- Get All Selected Objects
Step 3: Join the Quick Drop Enthusiasts Group
Quick Drop can be used to drop functions from the palettes faster without having to remember where the VIs are. It also includes a feature called Quick Drop shortcuts.
A good ninja will not reinvent the wheel. See what tools are already out there, install the ones that you like, inspect them and learn how they were put together. Then start creating your own tools.
Here is a link to the List of Community Quick Drop Keyboard Shortcuts.
At Delacor, we have created a few shortcuts. For example, here is a simple one:
As part of their LabVIEW Style Guideline, one of our customers pushes all the error wires to the back of the block diagram. The video below shows how that Quick Drop shortcut works:
Step 4: Join the VI Analyzer Enthusiasts Group
If your team does not have a LabVIEW Style Guideline, you might be using the LabVIEW Style Checklist that ships with the LabVIEW help. Maybe you use the old approach of having one of the old-timers in your team review your code and point out all the style errors you make.
When we work with teams, we help them write their LabVIEW Style Guideline. We start with our own. However, with time, we have realized that not all LabVIEW developers read the LabVIEW Style Guideline for their team. We have realized that the best enforcer/encourager for following the team style is the use of VI Analyzer tests. You probably tried VI Analyzer once and decided to never run it again because it reminded you of your spouse pointing out every little detail you forgot. I agree with you, I don’t like running every single test on my code either.
At Delacor, we use different VI Analyzer configurations depending on the target audience for the code. We have also created a set of custom tests to have VI Analyzer do the hard job of pointing out style deviations before the code review happens.
My favorite test is the one that reports when a LabVIEW developer forgets to wire the error out terminal from the File Dialog VI. This short video shows the test in action and the Delacor Custom VI Analyzer Tests example (no audio):
The video below is a more extended description of our Delacor Custom VI Analyzer Tests package that we customize for our customers.
Step 5: Join the LabVIEW Shortcut Menu Plugins group
When I teach LabVIEW Core 1 and 2, I tell students that they will learn pretty quickly that the majority of LabVIEW actions start with a right click. Some old timers have not jumped on the Quick Drop bandwagon because it does not start via a right-click action. However, starting with LabVIEW 2015, developers can extend the LabVIEW IDE by creating their own custom right-click menu options.
Same as before, a scripting ninja would not reinvent the wheel. Check out Darren’s Favorite Shortcut Menu Plug-Ins.zip and AQ Favorite Edit Time Menu Plug-Ins (and Outs).zip
Step 6 (Bonus step): Check out what is out there
VI Scripting is used in a lot more places than you might be aware of. For starters, within LabVIEW it is used to convert the DAQ Assistant Express VI into actual DAQmx code. It is also used with the new Channels, when creating class accessors, when creating messages for Actor Framework, etc.
Other examples outside of NI are:
BLT for LabVIEW from Studio Bods uses VI scripting to wrap your top-level VI with a nice splash screen and all the tracking VIs needed to get error reporting and exe usage information.
ViBox Quick Drop from SAPHIR is a set of NI LabVIEW Quick Drop plugins, it includes plugins made by SAPHIR as well as plugins from the community.
Steve Watts from SSDC and author of the Software Engineering Approach to LabVIEW created a LabVIEW Component Builder. Steve calls LabVIEW Components what others call Action Engines (or functional globals that do a lot more than just read/write data).
Falling Shortcuts by Darren Nattinger is a game to practice and learn your Quick Drop shortcuts.
The LabVIEW Method Viewer that allows you to see not only the list of instances available for a dynamic dispatch method but also their diagram. Very useful tool if you program a lot of classes.
And of course, the DQMH Productivity tools shown below 🙂
*Of course, if you decide that you don’t want to spend your time becoming a VI Scripting Ninja, you can always hire us at Delacor and we will do it for you!