[fpc-pascal] Forcing a text file to use a predefined handle
Michael Van Canneyt
michael at freepascal.org
Sat Dec 20 18:41:57 CET 2008
On Sat, 20 Dec 2008, Mark Morgan Lloyd wrote:
> 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, '');
> Rewrite(Error);
> TextRec(Error).Handle:= 2;
>
> or in the case of Delphi:
>
> program Meta2;
> ..
> Assign(Error, '');
> Rewrite(Error);
> TTextRec(Error).Handle:= GetStdHandle(STD_ERROR_HANDLE);
>
> Is there a correct and portable way to do this using FPC?
I would think that
TTextRec(Error).Handle:=TTextRec(StdOut).Handle
Does the trick ?
Michael.
More information about the fpc-pascal
mailing list