[fpc-pascal] redirecting stdout
Sven Barth
pascaldragon at googlemail.com
Sun Jul 18 13:31:20 CEST 2010
Hi again!
I forgot to mention:
If you want to redirect StdOut (or Output as the variable is called in
Pascal) you need to assign a new TextFile to Output (but keep the old
one around and assign it back later when your application is terminating).
Example:
var
oldoutput, f: TextFile;
begin
AssignFile(f, 'somefile');
Rewrite(f);
oldoutput := Output;
Output := f;
Writeln('Hello World'); // this is send to Output
Output := oldoutput;
CloseFile(f);
end.
More information about the fpc-pascal
mailing list