On Sun, 18 Jul 2010, Bernd wrote:

OK, I got it working now. Just in case somebody else is googling for
something like this:

first I define a class TDebugStream that will later replace the standard output:

Type
 TDebugStream = class(TStream)
   function Write(const Buffer; Count : Longint) : Longint; override;
 end;

implementation

function TDebugStream.Write(const Buffer; Count : Longint) : Longint;
var
 msg : ansistring;

begin
 result := count;
 SetLength(msg, count);
 move(buffer, PChar(msg)[0], count);
 OutputDebugString(PChar(TrimRight(msg)));
end;


then in my application i have two global variables:

var
 f : TextFile;
 s: TDebugStream;

and a procedure to redirect the output:

procedure redirect;
begin
s := TDebugStream.Create();
AssignStream(f, s);
Rewrite(f);
output := f;
end;

I think that simply

AssignStream(Output,S);
Rewrite(Output);

Probably would work as well.

Michael.
_______________________________________________
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal

Reply via email to