LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Print a string on a specific printer

Hello everyone,
I need some help.


I have to print a string in LabView. Previously the method used was to set on the option "Automatically print front panel every time VI completes execution" in the Print Options of the VI Properties.

Now, however, I should dynamically select the printer on which to print this string. The printer name is dynamically loaded from a text file.

Actually I'm trying to use the Print Report function (Easy Text Report.vi) that works fine, but it creates problems during the compiling: it create 3 folders in the directory where the executable is located (here the folders: NI_HTML, NI_report, NI_Standard Report) with all the VI "in freedom", not compiled but copied in there.

There are other methods to print a string through the name of the printer, or to solve this problem of creating random folders and VIs?

0 Kudos
Message 1 of 10
(3,669 Views)

Have you enabled the Build Option "Use 8.x file layout"?

 

That would normally create such kind of executables since the VIs in question have all the same names and that is the only way to prevent file name collisions when using the 8.x executable file format?

Rolf Kalbermatter
My Blog
0 Kudos
Message 2 of 10
(3,648 Views)

What do you mean?

I use LabView 2014. And I think it's strange that all VI used in the library are not included into the executable.

There is no other way to print a string with the printer selection?

0 Kudos
Message 3 of 10
(3,615 Views)

There are many ways to print something to a specific printer but none as simple as using the Report Generation functionality.

 

As to the option, I was refering to this:

 

LabVIEW 8.x layout.png

 

And yes there might be a reason that you enabled that at some point, if you reference files inside the executable somehow. But it is either a flat VI hierarchy inside the executable which requires VIs with the same name to be located outside the executable or a non-flat VI hierarchy and doing some proper file path calculation in the executable if you intend to reference VI files inside the executable.

Rolf Kalbermatter
My Blog
0 Kudos
Message 4 of 10
(3,606 Views)

Sorry, I had 1920x1080 resolution and 125% of character size so I didn't see that option (it was hidden).

 

The option is already on. I deselected it and there are no Vis or folder. If I check it again, the folders and VIs are generated again.

 

What is that option? Sincerely I didn't understand what you said of this option, sorry...

 

 

EDIT: ok the VIs are not generated but the application won't start correctly. What the hell...

0 Kudos
Message 5 of 10
(3,595 Views)

It seems that during the build of the application, it doesn't include the needed VIs. But many other VIs in "vi.lib" are included without this problem.

 

Can it be a problem because I'm running LW2014 32 bit? When the project is loading I see that some of the support VIs are not pointing into the library but directly in the Program Files (x86) directory...

0 Kudos
Message 6 of 10
(3,584 Views)

Your application does something internally that depends on the VIs being stored flat inside the executable. LabVIEW 8.x layout basicaly creates one flat archive inside the executable with all VIs stored in one level. That means it can not store VI files more than once with the same name. The Report Generatino Tools are however written using LabVIEW OOP which requires VIs to be named the same in order to allow dynamic dispatch.

 

If you deselect the LabVIEW 8.x layout option, the VIs are stored inside the executable in the same hierarchical structure as they are on disk in the source code of your application. That allows multple VIs with the same name to be placed inside the executable, but it does make the internal file hierarchy more complex.

 

Bsically you have two options:

 

1) figure out where in your appliction yoeu depend on internal paths of VIs to be in a flat order. Most likely this are Current VI path nodes that your application uses to strip twice a path element to find the directory in which the executable is located, for instance to find configuration files or similar. Replace this legacy code construct with an Application Directory property which will return the directory your executable is in rspectively the directory of your project file when you run your app in the devlopment environment.

 

2) Live with the extra files outside of your executable!

Rolf Kalbermatter
My Blog
0 Kudos
Message 7 of 10
(3,582 Views)

I can't. The code is huge, like 1800VIs and I can't waste time, it' not even my code.

And the second one is not acceptable.

 

So, returning to the main question: I need to print a string on a specified printer. I have the printer name and the string, what are other solution that you're talking about?

 

Can you provide me an example or the functions to be used?

0 Kudos
Message 8 of 10
(3,576 Views)

Someone that can help to print a string on a specified printer?

Is it possibile that is so complex to PRINT a simple thing as a string?

0 Kudos
Message 9 of 10
(3,558 Views)

Yes it is! Printing to a printer is pretty complex to do. Since Windows assumes all kinds of things and the printer needs to be setup and what else. Part of the problem is also that LabVIEW is not only a Windows application and printer handling on different OSes is VERY much different and complicated. So they developed the VI panel to printer option, which is supereasy to setup but doesn't allow things like a printer selection dialog and then the Report Generation Toolkit which allows more control but is developed with LabVIEW OOP which makes the VIs use the same names so you get external directories with VIs if you use the 8.x file layout.

 

You could try to use an external application like Microsoft Word and control it through ActiveX functions, but that is not going to be a trivial task to do either!

 

I'm sorry!

Rolf Kalbermatter
My Blog
0 Kudos
Message 10 of 10
(3,553 Views)