LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How can I send text file to printer port?

Can you post your vi?  If you look at the image I posted you should be able to reproduce my vi.  It should do exactly what you need.
0 Kudos
Message 11 of 35
(3,728 Views)


@filozof wrote:
I need to print a txt file from printer. I use sys exec.vi and bat file to do this. Bat file contains copy C:\plot.txt to lpt2  command. How can I do same issue with labview icons?


Hi filozof,

I'm not sure whether you understood(?) - no batch file is needed,  you could make a string="cmd /C "copy C:\plot.txt lpt2""

and wire that string to the System Exec.VI "command line" parameter.  System Exec.VI has a LabVIEW icon.

Or follow centerbolt's example and write to a "local printer" using the "Report Generation" VIs.  The fact that you're printing a VI's front panel proves this technique should work - what did you have "File Path" set to?

If you're feeling masochistic, it might even be possible to write directly to "LPT1" using VISA Write, Smiley Surprised though a form-feed command was often needed (in the old days) to see the last/only page of text.  To send a form-feed to the parallel-port, would be painful (but is possible). 

Cheers!

"Inside every large program is a small program struggling to get out." (attributed to Tony Hoare)
0 Kudos
Message 12 of 35
(3,725 Views)

yes it prints text file thank you so much.

Now i try your command at he sys exec icon without batch file. I write string  cmd/c"copy C:\plot.txt lpt2" at the command line sys exec.icon. But It can not print.

  

 

0 Kudos
Message 13 of 35
(3,705 Views)
Cmd /C "C:\plot.txt >lpt2" after using this command printed page include "1 file(s) copied.
0 Kudos
Message 14 of 35
(3,701 Views)
Cmd /C "C:\plot.txt >lpt2" after using that ,printed page shows just"1 file(s) copied.
0 Kudos
Message 15 of 35
(3,703 Views)
Maybe my mistake.

Try replacing "lpt2" with "prn2".

Shane.
Using LV 6.1 and 8.2.1 on W2k (SP4) and WXP (SP2)
0 Kudos
Message 16 of 35
(3,702 Views)
Printer prints only "1file(s) copied." Port is correct but I don't understand that when I use batch file,I can take print with c:\plot.txt  lpt2
instead of that, I write Cmd /C "copy C:\plot.txt >lpt2" in the command line in sys exec.vi, Printer prints only "1file(s) copied."sentence
0 Kudos
Message 17 of 35
(3,691 Views)
You may want to take a look at the Windows API VI libraries. You will find a library called winevent.llb. Within this library is a VI named FileMan Print File. You can simply wire a path to a file to this VI and Windows will use the default application to force the specified file to print. If you have a text file saved on dick, you can use this VI to print the text file. I hope this helps!

Mike D.
National Instruments
Applications Engineer
0 Kudos
Message 18 of 35
(3,679 Views)
If you have it working in a batch file, you can also call the batch file from LabVIEW, or simply use the text contained within the batch file for your system exec function (with cmd /C as prefix)

Shane
Using LV 6.1 and 8.2.1 on W2k (SP4) and WXP (SP2)
0 Kudos
Message 19 of 35
(3,674 Views)
I have sys exec. file and batch file.Batch file contain copy c:\plot.txt lpt2. When I write location of batch file in command line of sys exec. icon, I can print. But I want to improve that method. I don't want to batch file to copy c:\plot.txt lpt2.
 
Some friends said that no needed to batch file to copy, use Cmd/C"copy c:\plot.txt> lpt2" to command line.  when I do that, Printer sends only "1file(s) copied". It does not print text file.
0 Kudos
Message 20 of 35
(3,670 Views)