[comp.lang.pascal] Dual Output

reeder@reed.UUCP (Doug Reeder) (03/01/89)

The following approach is suitable for some programs and is standard pascal:

program anniversary(output,diskfile);
var
  diskfile : text;

procedure SendOutput(f : text);
begin
  write(f,'The 20th anniversary of humanity'); 
  writeln(f,'landing on the Moon is this July.');
  writeln(f);
end;

begin {main}
  rewrite(diskfile);
  SendOutput(output);
  SendOutput(diskfile);
end.

-- 
Doug Reeder                         USENET: ...!tektronix!reed!reeder
Box 971                             BITNET: reeder@reed.BITNET
Imperial University              from ARPA: tektronix!reed!reeder@berkeley.EDU
Trantor                             Box 971 Reed College,Portland,OR 97202

galvinp@lafcol.UUCP (Pablo) (03/01/89)

This is a reply to the question concerning dual output using Turbo
Pascal.

One thing that I have done in the past is to keep all of my writeln's
general in format.  For instance:

    writeln (OUTFILE,'text');

and then simply rewrite OUTFILE. This requires that you be able to go
through each write twice, once for the screen, then rewrite OUTFILE,
then out to the printer.  This isn't always convenient, but is sometimes
usefull.

If anyone else has anything to sy concerning this, I would also
appreciate suggestions, since in my CS classes, I often need to do
something like this.

Paul Galvin
(galvinp@lafcol) 

dmurdoch@watstat.waterloo.edu (Duncan Murdoch) (03/02/89)

Another idea for duplicating output would be to write a text file device driver
(in Turbo Pascal v 4 or 5).  It would be an output only driver that just wrote
everything sent to it out twice.  If you wanted duplicated output, you'd use
AssignDup (or something) to link output to this file; if you wanted screen-only,
you'd use AssignCrt; and for file-only, you'd use the regular Assign.  After
that, all writes to output would automatically do what you wanted.


Duncan Murdoch