[fpc-pascal] Forcing a text file to use a predefined handle

Mark Morgan Lloyd markMLl.fpc-pascal at telemetry.co.uk
Sat Dec 20 18:29:16 CET 2008

I can get a program compiled with Turbo Pascal to use the existing 
stderr handle for output like this:

PROGRAM Meta2(Input, Output, Error);
   Assign(Error, '');
   TextRec(Error).Handle:= 2;

or in the case of Delphi:

program Meta2;
   Assign(Error, '');
   TTextRec(Error).Handle:= GetStdHandle(STD_ERROR_HANDLE);

Is there a correct and portable way to do this using FPC?

Mark Morgan Lloyd
markMLl .AT. telemetry.co .DOT. uk

[Opinions above are the author's, not those of his employers or colleagues]

More information about the fpc-pascal mailing list