From: glen herrmannsfeldt on
Richard Maine <nospam(a)see.signature> wrote:
(snip on direct printer I/O)

> You wouldn't. The operating system probably won't let you. If you knew
> how to convince the operating system to let you directly access it, then
> you'd probably know the rest of the answer too. :-(

In MS-DOS you could, and it wasn't so unusual, either.

(snip on I/O through device drivers)

> If you really, really want to write directly to the printer, then dig
> out the hardware manuals for the I/O port. You won't do it with anything
> related to Fortran I/O (or C either). You'd be doing something more like
> manipulating registers in the I/O controller. Maybe you could get the
> registers memory mapped to Fortran variables... maybe.

On machines with memory mapped I/O (such as the Motorola 68x00 series)
it isn't so hard to do in C. You cast the address of the I/O
port to a C pointer, and then dereference the pointer.

For Intel processors, I/O ports are a different address space,
but display memory is in program memory space and, for MS-DOS
systems, commonly accessed directly by programs through C pointers.
BASIC users will remember PEEK and POKE for reading and writing
to memory, and memory mapped I/O ports.

-- glen

From: Steve Lionel on
On 3/29/2010 6:25 PM, Luka Djigas wrote:

> How would one go about printing directly to printer ? On a modern compiler (whichever one you like),
> how can one determine what units represent what output devices ?
> I tried searching a little through help in intel's and gfortran's which I have available, but I'm
> not sure what exactly am I really looking for.

The biggest problem is that most printers, nowadays, are "bitmap
rendering" devices that require some sort of driver running on the OS to
convert your text to something the printer can display. The exceptions
are those that accept a text-based language such as PostScript or HP-GL.

As others have said, you generally can't write directly to the printer.
Most operating systems allow you to create a pseudo-device that
"spools" output to the printer using some defaults. On Windows, this can
be set up for the LPT device.

Since you mentioned Intel, I'll comment that Intel Visual Fortran
(Windows) provides two sample applications, WinPrint and WinPrintDirect,
that enable printing to Windows-connected printers. WinPrint renders a
file as text, with the ability to specify fonts, spacing, duplex and
more. WinPrintDirect sends commands such as PostScript to a
Windows-connected printer.

If you have a printer that can accept text directly, look at the
instructions for your OS as to how to attach that to a pseudo-device
that you can open in Fortran and write to.

--
Steve Lionel
Developer Products Division
Intel Corporation
Nashua, NH

For email address, replace "invalid" with "com"

User communities for Intel Software Development Products
http://software.intel.com/en-us/forums/
Intel Software Development Products Support
http://software.intel.com/sites/support/
My Fortran blog
http://www.intel.com/software/drfortran
From: Terence on
I have to disagree with some of the postings.

You can still open a file (e.g. unit 2) with the file name 'PRN', like
this:-

OPEN(2,FILE='PRN',ACCESS='SEQUENTIAL',STATUS='NEW',
1 FORM='FORMATTED')

Then write to unit 2. And it works fine, thank you.

I just checked and four out of 60 operational Fortran-compiled
programs actually still use this.

I used to do this "all the time" to write various texts, reports,
sometimes direct RTF format (after first writing a header section and
ending with a trailer section), as the OP mentioned, graphics commands
intended for matrix printers of the old Epson type for histograms and
graphs.

However, in the other 56 programs I have allowed the user to edit an
offered default file name, (usually of form 'rootname.PRN') and he is
told he can also still input just PRN if he wants the local printer
directly.


From: robin on
"glen herrmannsfeldt" <gah(a)ugcs.caltech.edu> wrote in message news:horark$pt3$2(a)naig.caltech.edu...
| Luka Djigas <ldigas@___gmail___.com> wrote:
|
| > This is purely a theoretical issue for me, not a practical one,
| > but I'm interested in it, for curiosity's sake.
|
| > Imagine a modern workplace ... pc, win/linux (whatever fits
| > you the most), modern printer and so on.
|
| > Nowadays, when we use output units we usually mean either output
| > to file (number), or to screen (usually * for default output unit).
|
| > How would one go about printing directly to printer?
|
| These days, and actually for many years now, no-one prints
| directly to a printer.

Windows 3.1 is still in use, and printing is still direct to a printer.


From: robin on
"Luka Djigas" <ldigas@___gmail___.com> wrote in message news:jnc2r5pksj5inendg6kutnodcuhqk5bs0n(a)4ax.com...
| On Mon, 29 Mar 2010 22:50:28 +0000 (UTC), glen herrmannsfeldt <gah(a)ugcs.caltech.edu> wrote:
|
| >Luka Djigas <ldigas@___gmail___.com> wrote:
| >
| >These days, and actually for many years now, no-one prints
| >directly to a printer. Instead you write a disk file and then
| >spool that to a printer. There are systems that automate the
| >process of adding the queue entry (along with a famous TOPS-10 bug).
|
| Of course. This is, as I mentioned, a purely curiosity issue in view of practicality.
|
| But for the sake of argument let's say that I have an epson matrix printer (I do actually) sitting
| idleless connected to my computer (it does actually :) How would I / and can it be done anymore / go
| about printing to it directly from a program ?

You need to install a printer driver. If you can't find one specifically
for your Epson printer, look for a generic printed and install that.
Have your printer plugged into the parallel port while you do it
(i.e., LPT1).