*/
Check out and contribute to CodePedia, the wiki for developers.
*/

View \READSTOR.PAS

This is the second disk of the PASCAL TUTOR system. It has the

Submitted By: WEBMASTER
Rating: (Not rated) (Rate It)


(* Chapter 11 - Program 3 *)
program Read_And_Store_A_File;

var Read_File        : text;
    Input_File_Name  : string[12];
    Write_File       : text;
    Output_File_Name : string[12];
    Line_Number      : integer;
    Big_String       : string[80];
    Read_File_OK     : boolean;

begin
   Write('Enter input file name ');
   Readln(Input_File_Name);
   Assign(Read_File,Input_File_Name);
   {$I-}
   Reset(Read_File);
   {$I+}
   Read_File_OK := (IOResult = 0);
   if Read_File_OK then begin
      Write('Enter output file name ');
      Readln(Output_File_Name);
      Assign(Write_File,Output_File_Name);
      Rewrite(Write_File);

      Line_Number := 1;
      while not Eof(Read_File) do begin
         Readln(Read_File,Big_String);
         Write(Write_File,Line_Number:5,'  ');
         Writeln(Write_File,Big_String);
         Line_Number := Line_Number + 1;
      end;
      Close(Read_File);
      Close(Write_File);
   end
   else
      Writeln('Input file doesn''t exist, execution aborted');
end(* of program *)

corner
© 1996-2008 CommunityHeaven LLC. All rights reserved. Reproduction in whole or in part, in any form or medium without express written permission is prohibited.
Violators of this policy may be subject to legal action. Please read our Terms Of Use and Privacy Statement for more information.
North American business development: Nicolai Wadstrom. Publisher: Lars Hagelin.