[comp.lang.pascal] DUEL OUTPUT Turbo Pascal

mal@hjuxa.UUCP (LEACH) (03/07/89)

There may be hope for you.  With turbo pascal 4.0 (absent w/ 5.0) is
an example of a device driver called auxinout.pas.  This source file
sets up a unit that is a device driver for the AUX port.  For your
purposes though, it also shows how TP really does I/O, i.e., what
really happens when you use REWRITE, WRITELN etc.  What you could
do is modify that program, gutting out all of the specifics for the AUX
port, and modifying the portions where characters are actually written
out to streams.  This could probably be done fairly painlessly and it
will allow you to take advantage of all the "smarts :-)" of the write
command.

What auxinout.pas really shows you is a structure that you get when
you open a file, i.e., pointers to putchar routines that will be used
with that file.  By modifying that putchar routine to do 2 putchars,
1 to (pardon my C) stdio and the other to stdprt.

I wish I had thought of this earlier, I once had a simaler problem
which I solved by, sortof duplicating sprintf by using, I think,
the STR function (the one that returns a string given an integer)

Good Luck,

-- 
Michael A. Leach   uucp:    {decvax,clyde,rutgers,decuac}!hjuxa!mal
		   email:   hjuxa!mal@decuac.dec.com  OR  leach@unxa.dec.com   

abcscnuk@csuna.csun.edu (Naoto Kimura) (03/09/89)

In article <1302@hjuxa.UUCP> mal@hjuxa.UUCP (LEACH) writes:
]There may be hope for you.  With turbo pascal 4.0 (absent w/ 5.0) is
]an example of a device driver called auxinout.pas.  This source file
]sets up a unit that is a device driver for the AUX port.  For your
]purposes though, it also shows how TP really does I/O, i.e., what
]really happens when you use REWRITE, WRITELN etc.  What you could
]do is modify that program, gutting out all of the specifics for the AUX
]port, and modifying the portions where characters are actually written
]out to streams.  This could probably be done fairly painlessly and it
]will allow you to take advantage of all the "smarts :-)" of the write
]command.
] ... (text deleted) ...

The example text file driver helped quite a bit in trying to modify some
TP 3.0 interrupt driven routines I had for sending stuff through the
serial port.

If you didn't see the "Logger" unit that I posted a few weeks ago, it
implements what the original poster wanted.  As far as I have tested, it
will not only work with stdin and stdout but will also work if the
output is sent through the CRT unit.  It will also log what is going
through "input."  As long as you don't reassign the file variables
"input" or "output" everything works fine.   If you missed it, I can
send you a copy.

>Michael A. Leach   uucp:    {decvax,clyde,rutgers,decuac}!hjuxa!mal

                //-n-\\			 Naoto Kimura
        _____---=======---_____		 (abcscnuk@csuna.csun.edu)
    ====____\   /.. ..\   /____====
  //         ---\__O__/---         \\	Enterprise... Surrender or we'll
  \_\                             /_/	send back your *&^$% tribbles !!