*/
Check out and contribute to CodePedia, the wiki for developers.
*/

View \LOGDEMO.PAS

Supplement Turbovision/object Windows Stream

Submitted By: WEBMASTER
Rating: (Not rated) (Rate It)


{$B-}   { Use fast boolean evaluation. }

program logdemo;

{ Demonstrates use of TLogFilter }

uses
  {$ifdef windows}
  wobjects,wincrt,
  {$else}
  objects,
  {$endif windows}
  streams;

var
  i : integer;
  inlog,log : PLogFilter;

begin
  { Log both input and output to Logdemo.out }

  new(log, init( new(PDOSStream, init('Logdemo.out',stCreate))));

  log^.log(input);
  log^.log(output);

  writeln('This is the Logdemo program, which logs input and output');
  writeln('to LOGDEMO.OUT');
  write('Enter an integer:');
  readln(i);
  writeln('Logging will now be turned off.');

  if not log^.unlog(input) then;   { This is one way to stop logging. }
  close(output);       { This is another way. }

  { Re-open output; input was never closed. }
  rewrite(output);

  writeln('This line will not be logged.');
  write('Enter another integer:');
  readln(i);
  writeln('Logging will be turned back on now.');

  log^.log(input);
  log^.log(output);

  writeln('This line will be logged to the file.');

  writeln('All done now; close the log.');

  dispose(log,done);

  writeln('The log has been closed, so this line won''t be logged.');
end.

corner
© 1996-2008 CommunityHeaven LLC. All rights reserved. Reproduction in whole or in part, in any form or medium without express written permission is prohibited.
Violators of this policy may be subject to legal action. Please read our Terms Of Use and Privacy Statement for more information.
North American business development: Nicolai Wadstrom. Publisher: Lars Hagelin.