LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Command line tool that returns a value

Solved!
Go to solution
Is it possible to compile a VI to function as a command line tool that takes arguments and returns a value? I need to create some commands that will be launched from a scripting shell and return values that will be used in the script to evaluate the results. If this is possible, what is the type and range of values can be returned? I have seen some posts about hiding the front panel, but none about returning a value to the calling shell.
Timothy Klingerman
0 Kudos
Message 1 of 5
(5,695 Views)

The easiest way (from my point of view) is following: compile your VI into DLL, then call this DLL from small "wrapper" command-line application (written in C) and return desired values as you want.

 

Andrey.

0 Kudos
Message 2 of 5
(5,684 Views)
Suppose I need to return a position value calculated in the VI. How would I get the value back from the DLL to the Console Application?
Timothy Klingerman
0 Kudos
Message 3 of 5
(5,674 Views)

Quite easy.

 

Let's say - you have VI like this:

 

01-SimpleSubVI.png

 

Now you should build VI into DLL. Then in build options prototype looks like this:

 

02-Prototype.png

 

Now just call DLL from your console application:

 

03-CCode.png

 

A little bit more complicated situation occur if you want to transfer whole command line parameters as string to your SubVI without conversion:

 

02-AdvVI.png

Then prototype looks like this:

 

04-Prototyp.png 

 

 

Now you need to transfer array of LabVIEW-strings from external application to the DLL something like that:

 

05-CCode.png

 

(you can link lvrt.dll statically or dynamically).

 

And results:

 

06-Result.png

 

with best regards,

 

Andrey.

Message Edited by Andrey Dmitriev on 06-30-2009 04:14 PM
Message 4 of 5
(5,647 Views)
Solution
Accepted by topic author klingerman

Andrey,

 

Thanks for all your help. The only thing your answer lacked for me was that I am using C#. In this case, you simply have to add some code to handle an unmanaged DLL like this:

 

using System.Runtime.InteropServices;

public class Win32

{

[DllImport("Drive Letter:\\path to dll\\DLL Name.Dll")]

public static extern double Testing();

}

 

 After adding this code to Import the DLL into a class of your choice, you can call the function to run the LabVIEW VI in the library.

 

Best regards,

 

Timothy

 

 

Message Edited by klingerman on 06-30-2009 02:29 PM
Timothy Klingerman
0 Kudos
Message 5 of 5
(5,613 Views)