Paul,
I tried to supplement your answer by noting that if the printer is a PostScript or Windows Printer, this approach won't work. Also, there are some ports that have a name as far as Windows is concerned, but you don't seem to be able to send straightforward Fortran output to them (I think various USB ports might be mentioned here - although these do tend to have Windows Printers on them).
Hence, for foolproof output, one needs to make sure that the Fortran output goes via the printer driver. In the callback section of a call to winio@ I use a sequence such as:
... 'PRINTER_OPEN',8,Printing_FUNCTION ...
to connect Fortran Unit 8 to a user-selectable printer, and then go on to 'Printing_FUNCTION' to do the actual formatted writing using Fortran write statements. This always works, regardless of whether the printer is PostScript, a Windows Printer, etc.
It occurred to me that if one was running a non-windows application, one might still need to go through windows to make sure that writing would work. So I knocked up the following:
WINAPP
OPTIONS (INTL)
PROGRAM TRY
INCLUDE 'WINDOWS.INS'
CHARACTER*40 DEV, PORT
IA = SELECT_PRINTER@ (DEV,PORT)
OPEN (8, FILE=DEV)
WRITE(*,*) 'DEV=', DEV, ' PORT=',PORT
WRITE(8,*) 'Got it in one!'
CLOSE (8)
END
(I also tried FILE=PORT in the OPEN statement instead of FILE=DEV).
A good try, but it doesn't work. My printer is a networked HP colour laserjet. The SELECT_PRINTER@ gave me the printer selection, and my pop-up window showed me the correct info for the selected printer. However, my message went to a file, not to the device or port.
I was left wondering what use SELECT_PRINTER@ is, and also how to send output via the windows printer driver even from a console app. The OPEN_PRINTER@ and OPEN_PRINTER1@ functions seem to be for graphics only, and thus are not equivalent to the standard callback functions PRINTER_OPEN and PRINTER_OPEN1.
Incidentally, CHARACTER*20 (as recommended in the FTN95.chm) isn't long enough - at least not for my printer.
I read, some time ago, in the comp.lang.fortran group that Fortran only has files, not devices, in the standard, and so writing to a device is an extension.
Regards
Eddie