home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / ipo-101.zip / Samples.zip / CAT.PAS < prev    next >
Pascal/Delphi Source File  |  1998-11-15  |  793b  |  37 lines

  1. (*****************************************************************
  2. ** PURPOSE: Writes one or more files to the standard output.
  3. **          Similar to the UNIX command 'cat'
  4. *)
  5. program cat(output);
  6. var
  7.    i : integer;
  8.  
  9.    procedure ShowSyntax;
  10.    begin
  11.       writeln('cat: Writes one or more files to the standard output');
  12.       writeln('Syntax: cat files ...');
  13.       halt
  14.    end;
  15.  
  16.    procedure write_file(name : string);
  17.    var
  18.       f : text;
  19.       c : char;
  20.    begin
  21.       assign(f, name);
  22.       reset(f);
  23.       while not eof(f) do
  24.           begin
  25.               read(f, c);
  26.               write(c)
  27.           end;
  28.       close(f)
  29.    end;
  30.  
  31. begin
  32.    if paramcount = 0 then
  33.       ShowSyntax;
  34.    for i := 1 to paramcount do
  35.       write_file(paramstr(i))
  36. end.
  37.