home *** CD-ROM | disk | FTP | other *** search
/ Programmer 7500 / MAX_PROGRAMMERS.iso / PASCAL / STREAM11.ZIP / LOGDEMO.PAS < prev    next >
Encoding:
Pascal/Delphi Source File  |  1992-03-31  |  1.0 KB  |  47 lines

  1. program logdemo;
  2.  
  3. { Demonstrates use of TLogFilter }
  4.  
  5. uses
  6.   objects, streams;
  7.  
  8. var
  9.   i : integer;
  10.   inlog,log : PLogFilter;
  11.  
  12. begin
  13.   { Log both input and output to Logdemo.out }
  14.  
  15.   new(log, init( new(PDOSStream, init('Logdemo.out',stCreate))));
  16.  
  17.   log^.log(input);
  18.   log^.log(output);
  19.  
  20.   writeln('This is the Logdemo program, which logs input and output.');
  21.   write('Enter an integer:');
  22.   readln(i);
  23.   writeln('Logging will now be turned off.');
  24.  
  25.   if not log^.unlog(input) then;   { This is one way to stop logging. }
  26.   close(output);       { This is another way. }
  27.  
  28.   { Re-open output; input was never closed. }
  29.   rewrite(output);
  30.  
  31.   writeln('This line will not be logged.');
  32.   write('Enter another integer:');
  33.   readln(i);
  34.   writeln('Logging will be turned back on now.');
  35.  
  36.   log^.log(input);
  37.   log^.log(output);
  38.  
  39.   writeln('This line will be logged to the file.');
  40.  
  41.   writeln('All done now; close the log.');
  42.  
  43.   dispose(log,done);
  44.  
  45.   writeln('The log has been closed, so this line won''t be logged.');
  46. end.
  47.