Coyote's Guide to IDL Programming

Printing a Text File from Within IDL

QUESTION: I am creating a text output file in one of my IDL procedures. I would like to be able to send this file directly to the printer. I've tried the PRINTER device, but that doesn't work at all. Can this be done in IDL?

ANSWER: You are right, the PRINTER device does not work at all. Only IDL graphics commands can be sent to the printer via the PRINTER device.

In fact, there is no standard way to send a text file to a printer from within IDL. Odd, isn't it?

What this means is that you have to go outside of IDL to accomplish this task. For example, on UNIX machines you can usually spawn an lpr command. Suppose that your text file was named data_summary.txt. You could print it from within IDL with a command similar to this:

   Spawn, 'lpr '+ 'data_summary.txt'

On Windows machines I like to use a small freeware program named PrintFile to print text files. The PrintFile program can be found on Peter Larup's web page.

To print this text file from within IDL on my Windows XP machines, I can type this:

   IDL> Spawn, 'Start C:\"Program Files"\printfile\prfile32.exe data_summary.txt'

Google
 
Web Coyote's Guide to IDL Programming