Example Code

Calling Simple LabVIEW Code From DIAdem Using VB Script

Products and Environment

This section reflects the products and operating system used to create the example.

To download NI software, including the products shown below, visit ni.com/downloads.

    Software

  • Diadem
  • LabVIEW

Code and Documents

Attachment

Description

Overview

This example will show you how to load a LabVIEW VI into memory, pass in data and retrieve data using VB script from DIAdem.

 

Description

Using the LVRuntime object and methods in VB script, we can use LabVIEW VIs to perform tasks not possible in DIAdem. This example shows how to use a simple VI from DIAdem script. For more information please see the following whitepaper:

Calling a LabVIEW SubVI with DIAdem

 

Requirements

  • LabVIEW 2012 Run-Time Engine (or compatible)
  • DIAdem 2012 (or compatible)

 

Steps to Implement or Execute Code

  1. Open the "Call LabVIEW VI in DIAdem 2012.VBS" script from DIAdem
  2. Run the script from toolbar of through the menu Script -> Run VBS Script
  3. See attached files for the example code

 

Additional Information or References

VBS Script Code:

 

Option Explicit 'Forces the explicit declaration of all the variables in a script.
'Set up variables
Dim PathtoVI, VI, Answer

'Build VI filepath from path of script
PathtoVI = CurrentScriptPath + "Two Variables Add Operation 2012 NIVerified.vi"

'set LabVIEW Run Tim version
LVRuntime.Init "12.0"

'Load VI into memory for use
Set VI = LVRuntime.LoadVI (PathtoVI)
'Pass inputs into VI
VI.SetControlValue "input 1", 15
VI.SetControlValue "input 2", 18
'Do not synchronously start VI
VI.Run False

'Get output from VI
Answer = VI.GetControlValue ("output")
'Shows output in a dialog box
Call msgboxdisp (Answer)
'Unload LabVIEW runtime and VI
LVRuntime.DeInit

 

**This document has been updated to meet the current required format for the NI Code Exchange.**

Daniel G.
Semiconductor & Wireless
National Instruments

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