Developer Center Resources

cancel
Showing results for 
Search instead for 
Did you mean: 

Inter-Application Communication: Command Line

 

» Inter-Application Communication » Command Line

Description

In most languages, applications can be written to accept command line arguments when they are launched. These arguments are simply parameters passed to the application.

 

LabVIEW can communicate with a 3rd party application by launching it through the command line and passing in data as command line arguments. The application can then perform specific tasks based on these arguments. The application can then return data by writing out to the standard output or standard error streams, and LabVIEW can read the data in these streams.

 

The System Exec VI allows developers to access the command line from LabVIEW and launch 3rd party applications. The System Exec VI also returns the output of the standard output and standard error streams.

CommandLine 01.png

Likewise, LabVIEW VIs and executables can be launched from the command line and can be passed command line arguments. These arguments can be accessed in LabVIEW through the use of a Property Node. Since the arguments are passed in as strings, parsing might be necessary to use the arguments appropriately.

 

The main drawback of using the Command Line as a method for Inter-Application communication is that all the data is passed at the time the application is launched and no more data can be sent.

Example Use-Case

The CommandLine.vi LabVIEW example that ships with LabVIEW (<LabVIEW>\examples\viserver\cmdline.llb\CommandLine.vi) demonstrates one useful way of using the command line.

 

This example is called by entering a string similar to the following in the command line:

"<LabVIEW>\labview.exe" "<LabVIEW>\examples\viserver\cmdline.llb\CommandLine.vi" -- /number:5 /boolean:0 /string:”National Instruments”

 

This call opens LabVIEW, then calls the CommandLine VI with multiple arguments inserted after the -- characters. The arguments being passed in are the number 5, the Boolean value 0, and the string "National Instruments". Note that each argument is separated by a space.

CommandLine 02.png

CommandLine.vi

Referring to the figure above:

  • The command line arguments are extracted and parsed into separate strings.
  • The strings are searched for relevant data, and that data is then extracted.

Code Example

Developer Zone Example Program: Command Line Options in LabVIEW Executables

 

The following examples can be found from the NI Example Finder in LabVIEW, by navigating to Help»Find Examples...

  • CommandLine.vi
    (Example Finder » Programmatically Controlling VIs » Dynamically Loading and Calling VIs)

     

          

Additional Resources

KnowledgeBase 1CNFGHFI: Using Command Line Arguments With A LabVIEW Executable

Calling Scripting Languages and Executables from LabVIEW

 

Jervin Justin
NI TestStand Product Manager