LabVIEW Idea Exchange

cancel
Showing results for 
Search instead for 
Did you mean: 
Alex_Pi

Return Value of LVbuilt.exe called in CMD with Params

Status: New

There is a method how to call a .exe with Parameters over the  ( http://digital.ni.com/public.nsf/allkb/17C3AD70493CE0208625666A00763364?OpenDocument)

But there seems to be no Way to give a Value to Return to the cmd as ReturnValue.

In C this would be expressed instead of

void main(void)

as 

int main (char *Args[])

{

return = x; // returns X as return value back to cmd

}

or similar.

 

The only way to do this now is to write a C DLL wrapper around the Exe and call this one to get a custom Return value. This is not very comfortable when you choose LabVIEW in order not to have to write in C.

Instead this should be included in the Build Specs just like with the Arguments. The Datatype and Data to be returned should be specified via Property nodes, and the Value should be passed back up to the CMD when finished.

BuildSpec.png

This is handy when using Batch scripts.

8 Comments
AristosQueue (NI)
NI Employee (retired)

Why a special property node? Why not configure in the build spec a particular integer on the top-level VI to be the return value? That way you don't have any special code on the diagram when you're running *not* in a built EXE.

Alex_Pi
NI Employee (retired)

I would be happy for anything that works. The property node thing only came up because the Commandline parameters worked this way with a property node.

James_McN
Active Participant

This would enable much better integration with a number of software engineering tools like CI servers.

 

I would suggest it should be an input to the exit labview primitive which would be consistent with a lot of other languages.

 

exit_function.png

James Mc
========
CLA and cRIO Fanatic
My writings on LabVIEW Development are at devs.wiresmithtech.com
dusl
Member

Hello.

Item : Enable return Value to the command line.

  1. Environment :

LabView 2013 SP 1 development system, OS - Win 7, see attached pic LV version

  1. Request:

LabVIEW application called from the command line with input parameters (invoked with certain arguments by an external application and batch file) will return the results (values) string into same command line (Console Application) window.

Then external main application written in other language will read the results string.

  1. Investigation:
    1. Enable return value to Command Line is noted in

https://forums.ni.com/t5/LabVIEW-Idea-Exchange/Return-Value-of-LVbuilt-exe-called-in-CMD-with-Params...

 

but I didn’t found such option in my environment, see attached pic " Enable return value to Command Line Forum1".

  1. I found in the forum

https://forums.ni.com/t5/LabVIEW/Develop-a-command-line-application-using-LabVIEW/td-p/984272

following comments:

"The only way which I have found is creating command-line "wrapper", where LabVIEW-based DLL is called. So, you can not only pass parameters to command line application, but also return values from CLI app.

 Check this thread: Command line tool that returns a value

 Andrey."

 

  1. Also I found In forums that such solution requires additional C# development and compilation:

https://forums.ni.com/t5/LabVIEW/Command-line-tool-that-returns-a-value/m-p/935520?requireLogin=Fals...

 

But I don’t want to create .dll and definitely don't want to add more .exe developed in C#.

 

 

  1. Troubleshooting:

I attached simple SW, which I prepared to investigate the issue; it can be useful for your correct understanding.

The .bat file contains the required arguments to LabVIEW application, that performs the test process with the provided arguments and return results string.

 

  1. Questions:
    1. Is it possible to compile (build) a VI to an .exe function as a tool that returns a value to the same command line?
    2. How to activate "Enable return value to Command Line" feature?

Please, advise.

MyMySlava, ATE manager

James_McN
Active Participant

Hey,


The best available at the minute is the LabVIEW-CLI tool that we developed that has the C# wrapper pre-built. We've tried to make it as simple as possible. See https://github.com/JamesMc86/LabVIEW-CLI

 

NI announced some support for this in LabVIEW 2018 but that is still in beta at the minute.

James Mc
========
CLA and cRIO Fanatic
My writings on LabVIEW Development are at devs.wiresmithtech.com
dusl
Member

Hi, James

How your last post is related to my question? I'm looking for specific solution:Enable return value to Command Line Forum2.png

AristosQueue (NI)
NI Employee (retired)

dusl: I think James was just highlighting a workaround that was potentially better/easier than your current workarounds. I don't think it was meant to invalidate the utility of implementing the idea you request.

James_McN
Active Participant

Hi Dusl,

 

Yes sorry - reading back your post and answer your questions directly - that feature doesn't exist  The post above is a mockup of a desired feature in LabVIEW but it does not exist in the product. (this post is on the ideas exchange which is an area for feature requests in LabVIEW)

 

To answer your first question then - no, there is no way to achieve this in pure LabVIEW. What I posted was one workaround for this.

James Mc
========
CLA and cRIO Fanatic
My writings on LabVIEW Development are at devs.wiresmithtech.com