home *** CD-ROM | disk | FTP | other *** search
/ Shareware Overload / ShartewareOverload.cdr / progm / pascal2.zip / READSTOR.PAS < prev    next >
Pascal/Delphi Source File  |  1988-01-15  |  1KB  |  39 lines

  1.                                 (* Chapter 11 - Program 3 *)
  2. program Read_And_Store_A_File;
  3.  
  4. var Read_File        : text;
  5.     Input_File_Name  : string[12];
  6.     Write_File       : text;
  7.     Output_File_Name : string[12];
  8.     Line_Number      : integer;
  9.     Big_String       : string[80];
  10.     Read_File_OK     : boolean;
  11.  
  12. begin
  13.    Write('Enter input file name ');
  14.    Readln(Input_File_Name);
  15.    Assign(Read_File,Input_File_Name);
  16.    {$I-}
  17.    Reset(Read_File);
  18.    {$I+}
  19.    Read_File_OK := (IOResult = 0);
  20.    if Read_File_OK then begin
  21.       Write('Enter output file name ');
  22.       Readln(Output_File_Name);
  23.       Assign(Write_File,Output_File_Name);
  24.       Rewrite(Write_File);
  25.  
  26.       Line_Number := 1;
  27.       while not Eof(Read_File) do begin
  28.          Readln(Read_File,Big_String);
  29.          Write(Write_File,Line_Number:5,'  ');
  30.          Writeln(Write_File,Big_String);
  31.          Line_Number := Line_Number + 1;
  32.       end;
  33.       Close(Read_File);
  34.       Close(Write_File);
  35.    end
  36.    else
  37.       Writeln('Input file doesn''t exist, execution aborted');
  38. end.  (* of program *)
  39.