Saturday, December 08, 2007

Create a I/O redirection console application

Typical DOS application that may perform great function are GREP, MORE, SORT. These functions chain together via command redirection operators may perform complex operations. Here is a simple application written by Delphi to show how to deal with I/O redirection:
program pipe;

{$APPTYPE CONSOLE}

var S: string;
   F: TextFile;

begin
 AssignFile(F, '');
 Reset(F);
 while not Eof(F) do begin
   Readln(F, s);
   Writeln(s);
   Flush(F);
 end;
 CloseFile(F);
end.

No comments: