home *** CD-ROM | disk | FTP | other *** search
/ Programmer 7500 / MAX_PROGRAMMERS.iso / PASCAL / STREAM15.ZIP / LOGDEMO.PAS < prev    next >
Encoding:
Pascal/Delphi Source File  |  1993-03-27  |  1.2 KB  |  54 lines

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