home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / ipo-101.zip / Samples.zip / APPEND.PAS < prev    next >
Pascal/Delphi Source File  |  1997-09-19  |  2KB  |  57 lines

  1. (**************************************************************************
  2. ** This program appends two files together, writting the appended files out
  3. ** to a third file.
  4. *)
  5. program append(output, in1, in2, out);
  6. type
  7.    char_file = file of char;
  8. var
  9.    in1 : char_file;     (* first input file *)
  10.    in2 : char_file;     (* second input file *)
  11.    out : char_file;     (* output file *)
  12.  
  13.    (*******************************************************************
  14.    ** PURPOSE: Writes copies the contents of one file into another.
  15.    ** ARGUMENTS:
  16.    **    'f' - the input file
  17.    **    'g' - the output file
  18.    ** NOTES: It is up to the caller to open and close the files.
  19.    *)
  20.    procedure WriteFile(var f, g: char_file);
  21.    var
  22.       c : char;
  23.    begin
  24.       while not eof(f) do
  25.          begin
  26.             read(f, c);
  27.             write(g, c)
  28.          end
  29.    end;
  30.  
  31.    (**********************************************
  32.    ** PURPOSE: Writes a help screen and then halts
  33.    *)
  34.    procedure syntax;
  35.    begin
  36.       writeln('Appends two files together and writes the output to a third file');
  37.       writeln('Syntax');
  38.       writeln('   ivm append in1 in2 out');
  39.       writeln('where "in1" is the first input file');
  40.       writeln('and   "in2" is the second input file');
  41.       writeln('and   "out" is the output file');
  42.       halt
  43.    end;
  44.  
  45. begin
  46.    if paramcount <> 3 then
  47.       syntax;
  48.    rewrite(out);
  49.    reset(in1);
  50.    WriteFile(in1, out);
  51.    close(in1);
  52.    reset(in2);
  53.    WriteFile(in2, out);
  54.    close(out);
  55.    close(in2)
  56. end.
  57.