Skip to content

Instantly share code, notes, and snippets.

@aretche
Created February 18, 2015 23:43
Show Gist options
  • Save aretche/c161e18732faea30464e to your computer and use it in GitHub Desktop.
Save aretche/c161e18732faea30464e to your computer and use it in GitHub Desktop.
Ejemplo de redirección de salida estándar en FreePascal
program TestRedir;
{$mode objfpc}
uses
Sysutils, baseunix;
var
FOUT : ^File;
TempHOut : longint;
begin
New(FOut);
Assign (FOUT^, 'somefile.txt');
Rewrite(FOUT^);
TempHOut:=fpdup(StdOutputHandle);
fpdup2(FileRec(FOUT^).Handle,StdOutputHandle);
Writeln('Hello World');
fpdup2(TempHOut,StdOutputHandle);
Close(FOUT^);
fpclose(TempHOut);
end.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment