LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

External program fails unless it's allowed to send output to stderr

I have a fun issue I need to resolve. I have a command line utility written in CVI 2020 that takes a file name as an argument and converts the data in that file to another format. Specifially:

 

LBXWriter myfile.bgData -o myfile.lbx

 

It opens the .bgData file and writes a new .lbx file. Not complicated.  As it runs it spits a few status messages out to the console using fprintf(stderr, ...).

 

Okay, so that's been working a while now. I want to call it from within a LabWIndows 2020 GUI application. I'm using LaunchExecutableEx() and I pass it the executable name with the command line arguments. When it executes, a black window pops up with the status messages as they get generated and the desired output files appear. So far, so good.

 

I then added a command line option to suppress the status output. The hope is to get rid of the visible output window because it's distracting.  When I put a command line argument like "-quiet" in the code so that it simply doesn't call fprintf(), the code still appears to open the input file but it simply doesn't write the output file. It's as if writing to stderr somehow enables the capability to write output files.

 

Has anyone ever seen anything like this?

 

Thanks!

0 Kudos
Message 1 of 3
(976 Views)

Are you sure you use the built in fprintf() function and not some private wrapper in which you disabled the output when the -quiet flag is set? I have had similar issues in the past, not specifically LabWindows/CVI related and it usually was something like that, which was prompted by a feature request that I tried to solve in a quick and easy fix that eventually ended up being more complicated than first thought.

Rolf Kalbermatter
My Blog
0 Kudos
Message 2 of 3
(949 Views)

If your main problem is that the printf output window pops up, you can use the stdio functions to keep it in the background without changing the rest of the code.

0 Kudos
Message 3 of 3
(883 Views)