[comp.lang.pascal] Logging stdin and stdout to file in Turbo Pascal

abcscnuk@csuna.UUCP (Naoto Kimura) (02/20/89)

    Presently I'm working on a unit for Turbo Pascal (version 4.0 and
5.0) that will allow you to log I/O through the standard "input" and
"output" text files.  Presently I've gotten it to log what is going
through the "input" file, but have some difficulty in logging output
through the "output."

    I'm wondering if someone has already done this, or am I the first to
try this ?  If you've already done something like this I'd be interested
to hear from you and how you did it.  For those who haven't but would be
interested in the unit, drop me a line, and I'll send the code once I
get it to work.

    The reason I'm doing this is because someone here had done it here
already, but completely re-implemented the CRT unit to do it.  My
feeling was that it could be done without having to reimplement the CRT
unit and am presently developing my own unit that does the same to prove
my point.  The unit was developed for use in a class here at CSUN, and
the original was written for use with version 3 of the compiler.

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

fargo@pawl.rpi.edu (Ethan M. Young) (02/21/89)

You might try making a procedure which calls the write procedure and logs the
output to a file.  Eg:

PROCEDURE OutLog(VAR anything; code : integer);

VAR
   logfile : TEXT;   { Log file }

BEGIN  { OutLog }
   write(anything);
   Assign(logfile,'filename.ext');
   Rewrite(logfile);  { or Append(logfile) }
   CASE code OF
      0: writeln(logfile,'Output: ',anything,' performed on',date,' at ',time);
         ...
      ELSE: writeln(logfile,'Error: Output is unusually idiotic');
   END;   { CASE }
END;   { OutLog }

This little piece of code should do the trick.

Thank you and happy hunting!   Internet: fargo@pawl.rpi.edu
    ____    [> SB <]                     fargo@{paraguay|uruguay}.acm.rpi.edu
   /__      -=>??<=-        Bitnet (??): usergac0@rpitsmts.bitnet
  /   ARGO : 3000 years of regression from the year 4990

abcscnuk@csuna.UUCP (Naoto Kimura) (02/21/89)

Wouldn't you know it, first I make a posting requesting if anybody is
successful at what I've been able to get working halfway, and I figure
it out the next day...

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